Skip to content

Instantly share code, notes, and snippets.

@vjanelle
Created July 13, 2013 17:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vjanelle/5991408 to your computer and use it in GitHub Desktop.
Save vjanelle/5991408 to your computer and use it in GitHub Desktop.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This configuration requires Vagrant 1.1 or newer and two plugins:
#
# vagrant plugin install vagrant-hosts
# vagrant plugin install vagrant-auto_network
#
# If using Vagrant boxes provided by PuppetLabs, verions 4.2.10 of VirtualBox
# is reccomended.
#
# After installation, the following steps will spin up a master and agent that
# can communicate with each other:
#
# vagrant up
# vagrant ssh puppetagent
# sudo su -
# puppet agent -t --server=puppetmaster.boxnet
Vagrant.configure('2') do |config|
box_url = 'http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-fusion503-nocm.box'
box_name = 'centos-64-x64-fusion503-nocm'
config.vm.define :puppetmaster do |node|
# Create VMs running CentOS 6 with v4.2.10 of the VirtualBox guest
# extensions and no existing configuration management installations
# (puppet, chef, etc)
#
# An index of pre-built boxes can be found at:
#
# http://puppet-vagrant-boxes.puppetlabs.com
node.vm.box_url = box_url
node.vm.box = box_name
node.vm.hostname = 'puppetmaster.boxnet'
# Use vagrant-auto_network to assign an IP address.
node.vm.extend AutoNetwork::Mixin
node.vm.auto_network!
# Use vagrant-hosts to add entries to /etc/hosts for each virtual machine
# in this file.
node.vm.provision :hosts
# Bootstrap the latest version of Puppet on CentOS 6 and Set up a Puppet Master
# that automatically signs certs from agents.
#
# For operating systems other than CentOS 6, a collection of bootstrap
# scripts can be found here:
#
# https://github.com/hashicorp/puppet-bootstrap
#
# The Puppet Labs installation docs also have some useful pointers:
#
# http://docs.puppetlabs.com/guides/installation.html#installing-puppet-1
bootstrap_script = <<-EOF
if which puppet > /dev/null 2>&1; then
echo 'Puppet Installed.'
else
echo 'Installing Puppet Master.'
rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
yum --nogpgcheck -y install puppet-server
echo '*.boxnet' > /etc/puppet/autosign.conf
service iptables stop
service puppetmaster start
fi
EOF
node.vm.provision :shell, :inline => bootstrap_script
end
config.vm.define :puppetagent do |node|
node.vm.box_url = box_url
node.vm.box = box_name
node.vm.hostname = 'puppetagent.boxnet'
node.vm.extend AutoNetwork::Mixin
node.vm.auto_network!
node.vm.provision :hosts
# Set up Puppet Agent to automatically connect with Puppet master
bootstrap_script = <<-EOF
if which puppet > /dev/null 2>&1; then
echo 'Puppet Installed.'
else
echo 'Installing Puppet Agent.'
rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm
yum --nogpgcheck -y install puppet
fi
EOF
node.vm.provision :shell, :inline => bootstrap_script
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment