Files
puppet-openstack_dev_env/Vagrantfile
Dan Bode e04facc5a5 Add puppet master role
This commit adds a puppet master role for deploying
a fully functional puppet master with puppetdb
installed.

Adds the role in manifest/site.pp.
Add hosts entry to manifests/setup/hosts.pp
Add the definition in the vagrant file
Add new deps to Puppetfile
do not append timestamp to certname.

Add puppet master specific config settings to
setup/hosts.pp
2013-01-11 10:54:15 -08:00

160 lines
4.5 KiB
Ruby

def parse_vagrant_config(
config_file=File.expand_path(File.join(File.dirname(__FILE__), 'config.yaml'))
)
require 'yaml'
config = {'gui_mode' => "false", 'operatingsystem' => 'ubuntu'}
if File.exists?(config_file)
overrides = YAML.load_file(config_file)
config.merge!(overrides)
end
config
end
Vagrant::Config.run do |config|
v_config = parse_vagrant_config
if v_config['operatingsystem'] and v_config['operatingsystem'] != ''
if v_config['operatingsystem'].downcase == 'redhat'
os_name = 'centos'
config.vm.box = 'centos'
config.vm.box_url = 'https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box'
elsif v_config['operatingsystem'].downcase == 'ubuntu'
os_name = 'precise64'
config.vm.box = 'precise64'
config.vm.box_url = 'http://files.vagrantup.com/precise64.box'
else
raise(Exception, "undefined operatingsystem: #{v_config['operatingsystem']}")
end
end
ssh_forward_port = 2244
[
{'devstack' =>
{
'memory' => 512,
'ip1' => '172.16.0.2',
}
},
{'openstack_controller' =>
{'memory' => 2000,
'ip1' => '172.16.0.3'
}
},
{'compute1' =>
{
'memory' => 2512,
'ip1' => '172.16.0.4'
}
},
{'compute2' =>
{
'memory' => 2512,
'ip1' => '172.16.0.14'
}
},
{'nova_controller' =>
{
'memory' => 512,
'ip1' => '172.16.0.5'
}
},
{'glance' =>
{
'memory' => 512,
'ip1' => '172.16.0.6'
}
},
{'keystone' =>
{
'memory' => 512,
'ip1' => '172.16.0.7'
}
},
{'mysql' =>
{
'memory' => 512,
'ip1' => '172.16.0.8'
}
},
{'cinder' =>
{
'memory' => 512,
'ip1' => '172.16.0.9'
}
},
{ 'quantum_agent' => {
'memory' => 512,
'ip1' => '172.16.0.10'
}
},
{ 'puppetmaster' => {
'memory' => 512,
'ip1' => '172.16.0.31'
}
},
{ 'openstack_all' => { 'memory' => 2512, 'ip1' => '172.16.0.11'} }
#{'compute_1' =>
# {'ip1' => '172.16.0.4'}
#},
#{'compute_2' =>
# {'ip1' => '172.16.0.5'}
].each do |hash|
name = hash.keys.first
props = hash.values.first
raise "Malformed vhost hash" if hash.size > 1
config.vm.define name.intern do |agent|
ssh_forward_port = ssh_forward_port + 1
agent.vm.forward_port(22, ssh_forward_port)
# host only network
agent.vm.network :hostonly, props['ip1'], :adapter => 2
agent.vm.network :hostonly, props['ip1'].gsub(/(\d+\.\d+)\.\d+\.(\d+)/) {|x| "#{$1}.1.#{$2}" }, :adapter => 3
agent.vm.network :hostonly, props['ip1'].gsub(/(\d+\.\d+)\.\d+\.(\d+)/) {|x| "#{$1}.2.#{$2}" }, :adapter => 4
#agent.vm.customize ["modifyvm", :id, "--nicpromisc1", "allow-all"]
# natted network
#agent.vm.customize ["modifyvm", :id, "--nic3", "hostonly"]
#agent.vm.customize ["modifyvm", :id, "--nicpromisc3", "allow-all"]
#agent.vm.customize ["modifyvm", :id, "--macaddress2", 'auto']
#agent.vm.customize ["modifyvm", :id, "--macaddress3", 'auto']
agent.vm.customize ["modifyvm", :id, "--memory", props['memory'] || 2048 ]
agent.vm.boot_mode = 'gui' if v_config['gui_mode'] == 'true'
agent.vm.customize ["modifyvm", :id, "--name", "#{name}.puppetlabs.lan"]
agent.vm.host_name = "#{name.gsub('_', '-')}.puppetlabs.lan"
if name == 'puppetmaster' || name =~ /^swift/
node_name = "#{name.gsub('_', '-')}.puppetlabs.lan"
else
node_name = "#{name.gsub('_', '-')}-#{Time.now.strftime('%Y%m%d%m%s')}"
end
if os_name =~ /precise/
agent.vm.provision :shell, :inline => "apt-get update"
elsif os_name =~ /centos/
agent.vm.provision :shell, :inline => "yum clean all"
end
agent.vm.provision :puppet do |puppet|
puppet.manifests_path = 'manifests'
puppet.manifest_file = "setup/#{os_name}.pp"
puppet.module_path = 'modules'
#puppet.options = ['--verbose', '--show_diff', "--certname=#{node_name}"]
puppet.options = ["--certname=#{node_name}"]
end
agent.vm.provision :puppet do |puppet|
puppet.manifests_path = 'manifests'
puppet.manifest_file = 'site.pp'
puppet.module_path = 'modules'
#puppet.options = ['--verbose', '--show_diff', "--certname=#{node_name}"]
puppet.options = ["--certname=#{node_name}"]
end
end
end
end