-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
126 lines (107 loc) · 2.8 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
DOMAIN = 'test'
VIRTUAL_MACHINES = {
postgres1:
{
hostname: "postgres1.#{DOMAIN}",
ram: '512',
role: 'db',
networks:
[
{
ip: '172.21.0.5',
network: 'db-private'
}
]
},
web1:
{
hostname: "web1.#{DOMAIN}",
ram: '512',
role: 'web',
networks:
[
{
ip: '172.22.0.2',
network: 'web-private'
},
{
ip: '172.21.0.2',
network: 'db-private'
}
]
},
elasticsearch1:
{
hostname: "elasticsearch1.#{DOMAIN}",
ram: '512',
role: 'elasticsearch',
networks:
[
{
ip: '172.21.0.10',
network: 'db-private'
}
]
}
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'puppetlabs/centos-6.5-64-puppet'
config.ssh.forward_agent = true
config.vm.provision :host_shell do |host_shell|
host_shell.inline = './scripts/update_puppet.sh'
end
VIRTUAL_MACHINES.each do |name, cfg|
config.vm.define name do |vm_config|
# additional attributes
environment = cfg[:environment] || 'develop'
# configure basics
vm_config.vm.box = cfg[:box] if cfg[:box]
vm_config.vm.box_url = cfg[:box_url] if cfg[:box_url]
vm_config.vm.hostname = cfg[:hostname] if cfg[:hostname]
vm_config.hostmanager.aliases = cfg[:hostaliases] if cfg[:hostaliases]
if cfg[:networks]
cfg[:networks].each do |network|
vm_config.vm.network(
'private_network',
ip: network[:ip],
virtualbox__intnet: network[:name])
end
end
if cfg[:forwards]
cfg[:forwards].each do |guest, host|
vm_config.vm.network :forwarded_port, guest: guest, host: host
end
end
if cfg[:ram]
vm_config.vm.provider 'virtualbox' do |vb|
vb.memory = cfg[:ram]
end
end
if Vagrant.has_plugin?("vagrant-cachier")
vm_config.cache.scope = :box
vm_config.cache.synced_folder_opts = {
type: :nfs,
mount_options: ['rw', 'vers=3', 'tcp', 'nolock' ]
}
end
vm_config.vm.provision :hostmanager
vm_config.vm.provision 'puppet' do |puppet|
puppet.working_directory = '/vagrant/puppet' # this is for hiera
puppet.hiera_config_path = 'puppet/manifests/hiera.yaml'
puppet.module_path = [
'puppet/modules/vendor',
'puppet/modules/dogfood'
]
puppet.manifests_path = 'puppet/manifests'
puppet.facter = {
'vagrant' => '1',
'role' => cfg[:role],
'environment' => environment
}
end
end
end
end