forked from jeremykeen/vagrant-puppet-scaleio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
129 lines (105 loc) · 4.94 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- mode: ruby -*-
# vi: set ft=ruby :
# This configuration requires Vagrant 1.5 or newer and two plugins:
#
# vagrant plugin install vagrant-hosts ~> 2.1.4
# vagrant plugin install vagrant-auto_network ~> 1.0.0
#
Vagrant.require_version ">= 1.5.0"
require 'vagrant-hosts'
require 'vagrant-auto_network'
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
# these are the internal IPs, alternate IPs are auto-assigned using vagrant-auto_network
puppetmaster_nodes = {
'puppetmaster' => {
:ip => '192.168.50.9', :hostname => 'puppetmaster', :domain => 'scaleio.local', :memory => 512, :cpus => 1
}
}
# these are the internal IPs, alternate IPs are auto-assigned using vagrant-auto_network
scaleio_nodes = {
'tb' => { :ip => '192.168.50.11', :hostname => 'tb', :domain => 'scaleio.local', :memory => 1024, :cpus => 1 },
'mdm1' => { :ip => '192.168.50.12', :hostname => 'mdm1', :domain => 'scaleio.local', :memory => 1024, :cpus => 1 },
'mdm2' => { :ip => '192.168.50.13', :hostname => 'mdm2', :domain => 'scaleio.local', :memory => 1024, :cpus => 1 },
}
# (optional) specify download path, or comment out with # and specify
# $version and $rpm_suffix in site.pp file
download_scaleio = "ftp://ftp.emc.com/Downloads/ScaleIO/ScaleIO_RHEL6_Download.zip"
if download_scaleio
perform_download = <<-EOF
wget -nv ftp://ftp.emc.com/Downloads/ScaleIO/ScaleIO_RHEL6_Download.zip -O /tmp/ScaleIO_RHEL6_Download.zip
unzip -o /tmp/ScaleIO_RHEL6_Download.zip -d /tmp/scaleio/
cp /tmp/scaleio/ScaleIO_*_RHEL6*/*.rpm /etc/puppet/modules/scaleio/files/.
version=`basename /tmp/scaleio/ScaleIO_*_RHEL6_Download/EMC-ScaleIO-mdm* .el6.x86_64.rpm | cut -d- -f4,5,6`
sed -i "/\\$version = /c\\\\\\$version = \'$version\'" /etc/puppet/manifests/site.pp
EOF
end
Vagrant.configure('2') do |config|
config.vm.define puppetmaster_nodes['puppetmaster'][:hostname] do |node|
node_hash = puppetmaster_nodes['puppetmaster']
node.vm.box = 'puppetlabs/centos-6.6-64-nocm'
node.vm.hostname = "#{node_hash[:hostname]}.#{node_hash[:domain]}"
node.vm.provider "virtualbox" do |vb|
vb.memory = node_hash[:memory] || 1024
vb.cpus = node_hash[:cpus] || 1
end
node.vm.network :private_network, :ip => node_hash[:ip]
node.vm.network :private_network, :auto_network => true
# Use vagrant-hosts to add entries to /etc/hosts for each virtual machine
# in this file.
node.vm.provision :hosts
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/x86_64/puppetlabs-release-6-10.noarch.rpm
yum --nogpgcheck -y install puppet-server
echo '*.#{node_hash[:domain]}' > /etc/puppet/autosign.conf
puppet module install puppetlabs-stdlib
puppet module install puppetlabs-firewall
puppet module install puppetlabs-java
puppet module install emccode-scaleio
cp -Rf /opt/puppet/* /etc/puppet/.
#{perform_download}
puppet config set --section main parser future
puppet config set --section master certname puppetmaster.#{node_hash[:domain]}
/usr/bin/puppet resource service iptables ensure=stopped enable=false
/usr/bin/puppet resource service puppetmaster ensure=running enable=true
fi
EOF
node.vm.provision :shell, :inline => bootstrap_script
node.vm.synced_folder "puppet", "/opt/puppet"
end
scaleio_nodes.each do |node_name,value|
config.vm.provision :hosts do |provisioner|
provisioner.add_host puppetmaster_nodes['puppetmaster'][:ip],
["#{puppetmaster_nodes['puppetmaster'][:hostname]}.#{puppetmaster_nodes['puppetmaster'][:domain]}","#{puppetmaster_nodes['puppetmaster'][:hostname]}"]
end
config.vm.define node_name do |node|
node_hash = scaleio_nodes[node_name]
node.vm.box = 'puppetlabs/centos-6.6-64-nocm'
node.vm.hostname = "#{node_hash[:hostname]}.#{node_hash[:domain]}"
node.vm.provider "virtualbox" do |vb|
vb.memory = node_hash[:memory] || 1024
vb.cpus = node_hash[:cpus] || 1
end
node.vm.network :private_network, :ip => node_hash[:ip]
node.vm.network :private_network, :auto_network => true
#node.vm.provision :hosts
# Set up Puppet Agent to automatically connect with Puppet master
bootstrap_script = <<-EOF
ln -s /bin/rpm /usr/bin/rpm &> /dev/null
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/x86_64/puppetlabs-release-6-10.noarch.rpm
yum --nogpgcheck -y install puppet
puppet config set --section main server #{puppetmaster_nodes['puppetmaster'][:hostname]}.#{puppetmaster_nodes['puppetmaster'][:domain]}
puppet agent -t --detailed-exitcodes || [ $? -eq 2 ]
fi
EOF
node.vm.provision :shell, :inline => bootstrap_script
end
end
end