Created
February 26, 2012 19:12
-
-
Save dynamicguy/1918398 to your computer and use it in GitHub Desktop.
Vagrant configuration
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
#!/bin/sh | |
### this installs the 'add-apt-repository' tool | |
apt-get install -y python-software-properties | |
### add mathiaz' repository for newer puppet builds | |
add-apt-repository ppa:mathiaz/puppet-backports | |
### make sure we update the sources to include the above repo | |
apt-get update | |
### install puppet from there | |
apt-get install -y puppet | |
### make sure the service isn't running | |
### not needed - by default it's disabled | |
#/etc/init.d/puppet stop | |
### puppet is not configured to start by default so | |
### fix that manually now. eventually, the puppet | |
### configuration will fix this as well, but in the | |
### meantime, it's good to be able to restart. | |
sed -i.bak -e 's/START=no/START=yes/' /etc/default/puppet | |
### run puppet service | |
puppetd --server=puppet.example.com --environment=development --certname=`hostname`.ffffffff-ffff-ffff-ffff-ffffffffffff --verbose --waitforcert=60 |
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
################################## | |
### Custom additions from Krux | |
################################## | |
### Extensive documentation here: | |
### http://vagrantup.com/docs/vagrantfile.html | |
require 'etc' | |
owner = ENV['KRUX_MY_USERNAME'] || Etc.getlogin | |
hosts = { | |
### name ### port/ip prefix | |
"master" => "11", | |
"slave" => "12", | |
} | |
ports = { | |
"ssh" => 22, | |
"web" => 80, | |
"ssl" => 443, | |
"rabbit" => 5672, | |
"redis" => 6379, | |
"web_dev" => 8080, | |
"riak_pbc" => 8087, | |
"riak" => 8098, | |
} | |
################################## | |
### End custom additions from Krux | |
################################## | |
Vagrant::Config.run do |global_config| | |
hosts.each_pair do|type,prefix| | |
global_config.vm.define type do |config| | |
# All Vagrant configuration is done here. The most common configuration | |
# options are documented and commented below. For a complete reference, | |
# please see the online documentation at vagrantup.com. | |
# Every Vagrant virtual environment requires a box to build off of. | |
config.vm.box = "lucid64" | |
# The url from where the 'config.vm.box' box will be fetched if it | |
# doesn't already exist on the user's system. | |
config.vm.box_url = "http://files.vagrantup.com/lucid64.box" | |
# Boot with a GUI so you can see the screen. (Default is headless) | |
config.vm.boot_mode = :gui | |
################################## | |
### Custom additions from Krux | |
################################## | |
host_name = "vagrant-#{type}-#{owner}.example.com" | |
config.vm.customize do |vm| | |
vm.memory_size = 1024 | |
vm.name = host_name | |
end | |
config.vm.host_name = host_name | |
ports.each_pair do |port_name, port_number| | |
config.vm.forward_port( | |
port_name, port_number, sprintf( "%d%04d", prefix, port_number ).to_i | |
) | |
end | |
# Assign this VM to a host only network IP, allowing you to access it | |
# via the IP. | |
config.vm.network "192.168.254.#{prefix}" | |
### So, the bundled postinstall.sh file that comes with the lucid64.box | |
### has the following bits hardcoded: | |
# Installing chef & Puppet | |
# /opt/ruby/bin/gem install chef --no-ri --no-rdoc | |
# /opt/ruby/bin/gem install puppet --no-ri --no-rdoc | |
### This means it installs the latest version of puppet, | |
### which is currently one major version ahead of what | |
### the server runs (2.6 vs 2.7). And there's an incompatible | |
### change which makes the newer client not talk to the older | |
### server: http://projects.puppetlabs.com/issues/6117 | |
### So instead, we write our own shell provisioning script | |
### which simply apt-get installs puppet and starts it with | |
### the server, waitforcert & certname variables. | |
### Simple, but annoyingly necessary until we can pass the | |
### version along to the postinstall.sh script. | |
### set puppet_node to cert | |
#config.vm.provision :puppet_server do |puppet| | |
# puppet.puppet_server = "puppet.example.com" | |
# puppet.puppet_node = "#{host_name}.ffffffff-ffff-ffff-ffff-ffffffffffff" | |
#end | |
config.vm.provision :shell, :path => ".bin/run_puppet.sh" | |
### share your home folder to the guest | |
config.vm.share_folder "vagrant-#{type}-home", "/home/my_home", "~" | |
################################## | |
### End custom additions from Krux | |
################################## | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment