Build Puppet Clusters with Vagrant
$ cd ~/docs/propuppetex/chapter3
$ cat Vagrantfile
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos64"
config.vm.define "ppt" do |ppt|
ppt.vm.hostname = "puppet.boco.com.cn"
ppt.vm.network "private_network", ip: "192.168.50.3",
virtualbox__intnet: "gcptest-network"
ppt.vm.provider :virtualbox do |vbox|
vbox.customize ["modifyvm", :id, "--natnet1", "10.3/16"]
end
ppt.vm.provision :shell, path: "master.sh"
end
config.vm.define "web" do |web|
web.vm.hostname = "web.boco.com.cn"
web.vm.network "private_network", ip: "192.168.50.4",
virtualbox__intnet: "gcptest-network"
web.vm.provider :virtualbox do |vbox|
vbox.customize ["modifyvm", :id, "--natnet1", "10.3/16"]
end
web.vm.provision :shell, path: "web.sh"
end
end
$ cat master.sh
echo '*' > /etc/puppet/autosign.conf
sed -i '/[.*]/ a \ autosign = true' /etc/puppet/puppet.conf # add "autosign = true" in [main] and [agent]
echo "192.168.50.3 puppet.boco.com.cn puppet" >> /etc/hosts
echo "192.168.50.4 web.boco.com.cn web" >> /etc/hosts
mkdir /etc/puppet/manifests
cat > /etc/puppet/manifests/site.pp <<-EOF
node 'web' {
file { '/home/vagrant/aaa.conf':
content => 'this is made by puppet master!',
}
}
EOF
service iptables stop
$ cat web.sh
sed -i '1 a \ master = puppet' /etc/puppet/puppet.conf # add "master = puppet" after the line [main]
echo "192.168.50.3 puppet.boco.com.cn puppet" >> /etc/hosts
echo "192.168.50.4 web.boco.com.cn web" >> /etc/hosts
echo "proxy=http://10.21.3.31:8888" >> /etc/yum.conf
service iptables stop
Now run "puppet master --no-daemonize --verbose" on ppt, run "puppet agent --test" on web, you can file the file "aaa.conf" at /home/vagrant.