-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVagrantfile
100 lines (84 loc) · 2.72 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
# -*- mode: ruby -*-
# vi: set ft=ruby et ts=2 sw=2 :
ENV['VAGRANT_EXPERIMENTAL'] = 'typed_triggers'
ip_subnet = ENV.fetch('IP_SUBNET', '192.168.32')
puppet_version = ENV.fetch('PUPPET_VERSION', '')
puppet_release = puppet_version.empty? ? ENV.fetch('PUPPET_RELEASE', '8') : puppet_version.split('.').first
el_release = ENV.fetch('EL_RELEASE', '9')
el_os_name = ENV.fetch('EL_OS_NAME', 'centos')
def select_box(el_os_name, el_release)
return @box if @box
@box = ENV['BOX']
return @box unless @box.nil?
@box = case el_os_name
when 'centos'
if el_release.to_i > 7
"generic/#{el_os_name}#{el_release}s"
else
"generic/#{el_os_name}#{el_release}"
end
else
"#{el_os_name}/#{el_release}"
end
end
box = select_box(el_os_name, el_release)
def bolt_debug_options
return [] if ENV['DEBUG'].nil?
[
'--verbose',
'--trace',
'--log-level debug',
]
end
require 'yaml'
stream = YAML.safe_load(ENV.fetch('VERBOSE', 'true'))
native_ssh = YAML.safe_load(ENV.fetch('NATIVE_SSH', 'true'))
Vagrant.configure('2') do |config|
config.vm.box = box
config.ssh.forward_agent = true
config.vm.define 'puppet' do |puppetserver|
puppetserver.vm.provider 'virtualbox' do |vb|
vb.memory = '4096'
vb.cpus = 2
vb.name = 'puppet.vagrant'
end
puppetserver.vm.provider 'libvirt' do |libvirt|
libvirt.memory = '4096'
libvirt.cpus = 2
libvirt.qemu_use_session = false
end
puppetserver.vm.hostname = 'puppet.vagrant'
puppetserver.vm.network 'private_network', ip: "#{ip_subnet}.5"
puppetserver.vm.synced_folder '.', '/vagrant',
type: 'rsync',
rsync__exclude: ['spec/fixtures/modules/']
end
config.vm.define 'agent' do |agent|
agent.vm.provider 'virtualbox' do |vb|
vb.name = 'agent.vagrant'
end
agent.vm.provider 'libvirt' do |libvirt|
libvirt.qemu_use_session = false
end
agent.vm.hostname = 'agent.vagrant'
agent.vm.network 'private_network', ip: "#{ip_subnet}.6"
agent.vm.synced_folder '.', '/vagrant', disabled: true
end
config.trigger.before [:up, :provision, :reload], type: :command do |trigger|
trigger.info = 'Initializing bolt'
trigger.run = { inline: 'bolt module install' }
end
config.trigger.after [:up, :provision, :reload], type: :command do |trigger|
trigger.info = 'Running bolt plan'
trigger.run = {
inline: [
'bolt plan run role -t all --run-as root',
"puppet_release=#{puppet_release}",
"puppet_version=#{puppet_version}",
].concat(bolt_debug_options)
.concat(stream ? ['--stream'] : [])
.concat(native_ssh ? ['--native-ssh'] : [])
.join(' ')
}
end
end