-
Notifications
You must be signed in to change notification settings - Fork 8
/
Vagrantfile
85 lines (73 loc) · 3.56 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
# Define the puppet client VM configurations in this hash.
#
# Keys are used as both the VM name for Vagrant and
# to generate the hostname for the VM (e.g. #{key}.vm.local).
#
# Values are a hash of the following options:
# - :ip => The IP address of the client; required
# - :mem => The amount of RAM for the client; defaults to 4096
# - :cpus => The number of CPUs for the client; defaults to 2
#
# All clients will be added to the hosts file for each VM
$clients = {
:'lumify' => { ip: '192.168.33.109', mem: '6144', cpus: '4', },
:'lumify1' => { ip: '192.168.33.3', mem: '3072', cpus: '4', },
:'lumify2' => { ip: '192.168.33.4', mem: '3072', cpus: '4', },
:'lumify3' => { ip: '192.168.33.5', mem: '3072', cpus: '4', },
# :'vc-m1' => { ip: '192.168.33.11', mem: '1536', cpus: '1' },
# :'vc-m2' => { ip: '192.168.33.12', mem: '1536', cpus: '1' },
# :'vc-m3' => { ip: '192.168.33.13', mem: '1536', cpus: '1' },
# :'vc-hdn1' => { ip: '192.168.33.111', mem: '1536', cpus: '1' },
# :'vc-hdn2' => { ip: '192.168.33.112', mem: '1536', cpus: '1' },
# :'vc-hdn3' => { ip: '192.168.33.113', mem: '1536', cpus: '1' },
# :'vc-esn1' => { ip: '192.168.33.211', mem: '1024', cpus: '1' },
# :'vc-esn2' => { ip: '192.168.33.212', mem: '1024', cpus: '1' },
# :'vc-esn3' => { ip: '192.168.33.213', mem: '1024', cpus: '1' },
# :'vc-w1' => { ip: '192.168.33.9', mem: '1024', cpus: '1' },
}
def config_client(vm, name, ip_addr, mem, cpus)
vm.define name do |client|
client.vm.provision :shell, inline: "echo \"Configuring hostname\" && sed -i \'s/^HOSTNAME=.*$/HOSTNAME=#{name}.vm.local/\' /etc/sysconfig/network && hostname #{name}.vm.local"
client.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', "#{mem}"]
vb.customize ['modifyvm', :id, '--cpus', "#{cpus}"]
end
client.vm.network :private_network, ip: ip_addr
client.vm.provision :shell, path: 'vagrant/install_client.sh'
end
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'puppetlabs/centos-6.6-64-nocm'
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :machine
end
# Configure puppet yum repository; add 'echo' statement so provisioning is always
# successful since rpm has a non-0 exit code if the repository has already
# been added.
config.vm.provision :shell do |s|
s.inline = 'rpm -Uvh http://yum.puppetlabs.com/puppetlabs-release-pc1-el-6.noarch.rpm; \
echo "Configured puppet repository..."'
end
# Configure hosts file
config.vm.provision :shell, inline: 'echo "Configuring /etc/hosts" && cp /vagrant/vagrant/etc/hosts /etc/hosts'
# Configure client VMs
$clients.each { |host, params|
config.vm.provision :shell, inline: "echo #{params[:ip]} #{host} #{host}.vm.local >> /etc/hosts"
config_client(config.vm, host, params[:ip], params[:mem]||4096, params[:cpus]||2)
}
# Configure puppet VM
config.vm.define :puppet do |puppet|
puppet.vm.hostname = 'puppet.vm.local'
puppet.vm.provider :virtualbox do |vb|
vb.customize ['modifyvm', :id, '--memory', '4096' ]
vb.customize ['modifyvm', :id, '--cpus', '1' ]
end
puppet.vm.network :private_network, ip: '192.168.33.100'
puppet.vm.synced_folder 'puppet', '/etc/puppetlabs/code'
puppet.vm.provision :shell, path: 'vagrant/install_server.sh'
end
end