Skip to content

Instantly share code, notes, and snippets.

@double-z
Created May 15, 2013 02:58
Show Gist options
  • Save double-z/5581365 to your computer and use it in GitHub Desktop.
Save double-z/5581365 to your computer and use it in GitHub Desktop.
#!/bin/sh
set +x
echo "FYI: installing the RBEL repo"
rpm -Uvh http://rbel.co/rbel6
yum install -y rubygem-chef
yum install -y rubygem-chef-server
#rpm -Uvh http://rbel.frameos.org/rbel6
#echo "FYI: installing ruby and other development tools"
#yum -y install ruby ruby-devel ruby-ri ruby-rdoc ruby-shadow gcc gcc-c++ automake autoconf make curl dmidecode
#echo "FYI: installing rubygems from source"
#cd /tmp
#curl -O http://production.cf.rubygems.org/rubygems/$RUBYGEMS.tgz
#tar zxf $RUBYGEMS.tgz
#ruby $RUBYGEMS/setup.rb --no-format-executable
#cd -
#echo "FYI: installing chef"
#install Chef Gem
#gem install chef --no-ri --no-rdoc
echo "FYI: iptables"
#web interface
IPT=/sbin/iptables
# modules
# ip_nat_pptp = nat for p2p traffic.
modprobe ip_nat_pptp
# delete all existing rules.
$IPT -F
$IPT -Z
$IPT -t nat -F
$IPT -t mangle -F
$IPT -t nat -Z
$IPT -t nat -X
$IPT -X
# default behaviour
$IPT -P INPUT ACCEPT
$IPT -P FORWARD ACCEPT
$IPT -P OUTPUT ACCEPT
$IPT -A INPUT -p tcp --dport 4040 -j ACCEPT
#chef-server
$IPT -A INPUT -p tcp --dport 4000 -j ACCEPT
#amqp server
$IPT -A INPUT -p tcp -m multiport --dport 5672,4369,50229 -j ACCEPT
#search indexes (solr)
$IPT -A INPUT -p tcp --dport 8983 -j ACCEPT
#data store (couchdb)
$IPT -A INPUT -p tcp --dport 5984 -j ACCEPT
echo "FYI: selinux"
setsebool -P httpd_can_network_connect=on
echo "FYI: setup"
setup-chef-server.sh
echo "FYI: configuring chef server"
sed -i "s/http:\/\/localhost:4000/http:\/\/0.0.0.0:4000/g" /etc/chef/server.rb
#TODO: fix this later
gem uninstall chef --version 0.10.10
echo "FYI: restarting daemons"
#restarting daemons
/etc/init.d/chef-server restart
/etc/init.d/chef-server-webui restart
if [ -d "/vagrant" ]; then
rm /vagrant/validation.pem
cp /etc/chef/validation.pem /vagrant/validation.pem
rm /vagrant/webui.pem
cp /etc/chef/webui.pem /vagrant/webui.pem
fi
if [ -d "/home/vagrant" ]; then
cd /home/vagrant
mkdir -p .chef
cp /etc/chef/validation.pem .chef
cp /etc/chef/webui.pem .chef
chown -R vagrant .chef
#configure knife
sudo -u vagrant knife configure -i << EOF
.chef/webui.pem
.chef/validation.pem
EOF
sudo -u vagrant EDITOR=cat knife node create rabbit1 --no-editor
sudo -u vagrant EDITOR=cat knife node create rabbit2 --no-editor
sudo -u vagrant EDITOR=cat knife cookbook upload rabbitmq -o /media/cookbooks
cd -
fi
set -x
echo ""
echo ""
echo "Installation complete"
echo "You can now access your chef server"
for IP in `ip a | grep eth | grep inet | awk '{print $2}' | sed "s/\/[0-9]*//g"`
do
echo "chef-server: $IP:4000"
echo "chef-console: $IP:4040"
if [ -f "/vagrant/validation.pem" ]; then
echo "validation.pem: $IP:/vagrant/validation.pem"
fi
if [ -f "/vagrant/webui.pem" ]; then
echo "webui.pem: $IP:/vagrant/webui.pem"
fi
done
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.define :chef do |chef|
chef.vm.network :hostonly, "10.100.0.101", :netmask => "255.255.0.0"
chef.vm.host_name = "chef"
chef.vm.box = "oracle62"
chef.vm.forward_port 22, 2224
chef.vm.forward_port 80, 8081
chef.vm.forward_port 4000, 4000
chef.vm.forward_port 4040, 4040
chef.vm.provision :shell, :path => "chef-server-centos.sh"
chef.vm.share_folder("cookbooks", "/media/cookbooks", "../../cookbooks")
chef.vm.customize [
"modifyvm", :id,
"--name", "Chef Server",
"--memory", "740"
]
end
config.vm.define :rabbit1 do |rabbit1|
rabbit1.vm.network :hostonly, "10.100.0.102", :netmask => "255.255.0.0"
rabbit1.vm.host_name = "rabbit1"
rabbit1.vm.box = "oracle62"
rabbit1.vm.forward_port 22, 2225
rabbit1.vm.provision :chef_client do |chefc|
chefc.chef_server_url = "http://10.100.0.101:4000"
chefc.validation_key_path = "validation.pem"
chefc.json = {
"rabbitmq" => {
"use_hostsfile" => "true",
"use_iface" => "eth1"
}
}
chefc.add_recipe("rabbitmq::default")
#chefc.add_role("database")
chefc.log_level = :debug
end
rabbit1.vm.customize [
"modifyvm", :id,
"--name", "Rabbit1",
"--memory", "740"
]
end
config.vm.define :rabbit2 do |rabbit2|
rabbit2.vm.network :hostonly, "10.100.0.103", :netmask => "255.255.0.0"
rabbit2.vm.host_name = "rabbit2"
rabbit2.vm.box = "oracle62"
rabbit2.vm.forward_port 22, 2226
rabbit2.vm.provision :chef_client do |chefc|
chefc.chef_server_url = "http://10.100.0.101:4000"
chefc.validation_key_path = "validation.pem"
chefc.json = {
"rabbitmq" => {
"use_hostsfile" => "true",
"use_iface" => "eth1"
}
}
chefc.add_recipe("rabbitmq::default")
#chefc.add_role("database")
chefc.log_level = :debug
end
rabbit2.vm.customize [
"modifyvm", :id,
"--name", "Rabbit2",
"--memory", "740"
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment