Created
September 27, 2013 02:45
-
-
Save kongchen/6723532 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.define :puppetmaster do |puppetmaster| | |
puppetmaster.vm.hostname = "puppetmaster" | |
puppetmaster.vm.network :private_network, ip: "192.168.33.50" | |
puppetmaster.vm.box = "base" | |
puppetmaster.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box" | |
puppetmaster.vm.provision :shell, :inline => ' | |
/etc/init.d/iptables stop | |
yum install -y openssl openssl-devel vim-enhanced augeas | |
rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm | |
yum update -y puppet | |
chown -R puppet:puppet /var/lib/puppet | |
echo "192.168.33.50 puppet puppetmaster" >> /etc/hosts | |
augtool -s <<-EOF | |
set /files/etc/puppet/puppet.conf/master/certname puppetmaster | |
save | |
EOF | |
if [ ! -d "/etc/puppet/manifests" ]; then | |
mkdir /etc/puppet/manifests | |
fi | |
if [ ! -f "/etc/puppet/manifests/site.pp" ]; then | |
echo " | |
node default { | |
} | |
node /^puppetclient\-\d+$/ { | |
package { \"git\": | |
ensure => latest, | |
} | |
file { \"/etc/motd\": | |
mode => 444, | |
content => \"You \$hostname have been puppetized.\", | |
} | |
} | |
" > /etc/puppet/manifests/site.pp | |
fi | |
echo "*" > /etc/puppet/autosign.conf | |
puppet master --mkusers --verbose | |
' | |
end | |
# Manual setup of a puppet client | |
config.vm.define :puppetclient1 do |puppetclient1| | |
puppetclient1.vm.hostname = "puppetclient-1" | |
puppetclient1.vm.network :private_network, ip: "192.168.33.51" | |
puppetclient1.vm.box = "base" | |
puppetclient1.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box" | |
puppetclient1.vm.provision :shell, :inline => ' | |
/etc/init.d/iptables stop | |
yum install -y openssl openssl-devel vim-enhanced augeas | |
rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm | |
yum update -y puppet | |
chown -R puppet:puppet /var/lib/puppet | |
echo "192.168.33.50 puppet puppetmaster" >> /etc/hosts | |
augtool -s <<-EOF | |
set /files/etc/puppet/puppet.conf/main/runinterval 30 | |
save | |
EOF | |
puppet agent --waitforcert 0 --test | |
puppet agent | |
' | |
end | |
# Vagrant's automated setup of a puppet client | |
config.vm.define :puppetclient2 do |puppetclient2| | |
puppetclient2.vm.hostname = "puppetclient-2" | |
puppetclient2.vm.network :private_network, ip: "192.168.33.52" | |
puppetclient2.vm.box = "base" | |
puppetclient2.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box" | |
puppetclient2.vm.provision :shell, :inline => ' | |
/etc/init.d/iptables stop | |
chown -R puppet:puppet /var/lib/puppet | |
echo "192.168.33.50 puppet puppetmaster" >> /etc/hosts | |
' | |
puppetclient2.vm.provision :puppet_server do |puppet| | |
puppet.puppet_node = "puppetclient-2.example.com" | |
puppet.options = "--verbose --debug" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment