Last active
August 29, 2015 14:10
-
-
Save charlesjohnson/834651271f61a510586c to your computer and use it in GitHub Desktop.
Chef Provisioning snippet
This file contains 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
# vagrant_driver.rb | |
require 'chef/provisioning/vagrant_driver' | |
vagrant_box 'chef/ubuntu-12.04' | |
with_machine_options :vagrant_options => { | |
'vm.box' => 'chef/ubuntu-12.04' | |
} | |
# Number of webservers we want | |
num_webservers = 2 | |
# Create our array of hosts, append in as many webservers as we want | |
hosts = %w(dbserver balancer) | |
1.upto(num_webservers) do |i| | |
hosts << "web#{i}" | |
end | |
# Loop to build all of our hosts in order, offset at 20 for IP address final octet | |
hosts.each.with_index(20) do |hostname, ip| | |
machine hostname do | |
add_machine_options :vagrant_options => { | |
'vm.hostname' => "#{hostname}.chef-demo.com" | |
}, :vagrant_config => <<-EOM | |
config.vm.network :private_network, ip: '192.168.243.#{ip}' | |
EOM | |
chef_environment 'production' | |
run_list [ | |
'recipe[ohai_plugins::vagrant_ipaddress]', | |
'role[ubuntu_base]' | |
] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment