vagrant-em-demos 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/code/environments/plugin/hiera.yaml +17 -0
- data/code/environments/plugin/hieradata/deployment_zones/vagrant.yaml +1 -0
- data/code/environments/plugin/hieradata/nodes/puppetserver.yaml +2 -0
- data/code/environments/plugin/manifests/site.pp +14 -0
- data/code/environments/plugin/modules/profile/manifests/base/config.pp +11 -0
- data/code/environments/plugin/modules/profile/manifests/base/hosts.pp +13 -0
- data/code/environments/plugin/modules/profile/manifests/base/packages.pp +13 -0
- data/code/environments/plugin/modules/profile/manifests/base/vagrant.pp +39 -0
- data/code/environments/plugin/modules/profile/manifests/base.pp +8 -0
- data/code/environments/plugin/modules/profile/manifests/puppetserver.pp +20 -0
- data/code/environments/plugin/modules/role/manifests/puppet_enterprise.pp +1 -0
- data/code/environments/plugin/modules/role/manifests/puppetserver.pp +7 -0
- data/lib/vagrant/em/demos/Vagrantfile.rb +42 -0
- data/lib/vagrant/em/demos/adress_manager.rb +44 -0
- data/lib/vagrant/em/demos/command/cleanup.rb +29 -0
- data/lib/vagrant/em/demos/command/prepare.rb +35 -0
- data/lib/vagrant/em/demos/config.rb +20 -0
- data/lib/vagrant/em/demos/config_reader.rb +118 -0
- data/lib/vagrant/em/demos/defaults.yaml +54 -0
- data/lib/vagrant/em/demos/errors.rb +15 -0
- data/lib/vagrant/em/demos/models.rb +97 -0
- data/lib/vagrant/em/demos/plugin.rb +40 -0
- data/lib/vagrant/em/demos/types/agent.rb +26 -0
- data/lib/vagrant/em/demos/types/base.rb +333 -0
- data/lib/vagrant/em/demos/types/masterless.rb +37 -0
- data/lib/vagrant/em/demos/types/pe_agent.rb +33 -0
- data/lib/vagrant/em/demos/types/pe_master.rb +13 -0
- data/lib/vagrant/em/demos/types/ps_server.rb +16 -0
- data/lib/vagrant/em/demos/version.rb +9 -0
- data/lib/vagrant/em/demos.rb +12 -0
- data/vm-scripts/install_modules.ps1 +9 -0
- data/vm-scripts/install_puppet.ps1 +22 -0
- data/vm-scripts/install_puppet.sh +21 -0
- data/vm-scripts/install_puppet_agent.sh +17 -0
- data/vm-scripts/install_puppet_enterprise.sh +42 -0
- data/vm-scripts/install_puppet_server.sh +37 -0
- data/vm-scripts/run_puppet.ps1 +2 -0
- data/vm-scripts/setup_puppet.ps1 +37 -0
- data/vm-scripts/setup_puppet.sh +77 -0
- data/vm-scripts/setup_puppet_raw.ps1 +1 -0
- metadata +114 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module EM
|
3
|
+
class Agent < Base
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
if @model.protocol == "ssh"
|
7
|
+
setup_linux
|
8
|
+
else
|
9
|
+
setup_windows
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def setup_linux
|
16
|
+
add_shell_script_provisioner("install_puppet.sh")
|
17
|
+
@provisioners << {shell: {inline: 'systemctl stop puppet; pkill -9 -f "puppet.*agent.*"; true'}}
|
18
|
+
@provisioners << {puppet_server: {puppet_server: "#{@model.puppet_master}.#{@model.domain_name}", puppet_node: "#{@model.hostname}.#{@model.domain_name}", options: "--test"}}
|
19
|
+
@provisioners << {shell: {inline: "systemctl start puppet"}}
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_windows
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,333 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module EM
|
3
|
+
class Base
|
4
|
+
def self.setup(config, vm, model, provisioners, models)
|
5
|
+
new(config, vm, model, provisioners, models).setup
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(config, vm, model, provisioners, models)
|
9
|
+
@config = config
|
10
|
+
@vm = vm
|
11
|
+
@model = model
|
12
|
+
@provisioners = provisioners
|
13
|
+
@models = models
|
14
|
+
@root_path = File.expand_path("..", __FILE__) + "/../../../../../vm-scripts"
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup
|
18
|
+
configure_vm(@vm, @model)
|
19
|
+
configure_plugins(@config, @vm, @model)
|
20
|
+
configure_software_files(@config, @vm, @model)
|
21
|
+
configure_dhcp_fix(@config, @vm, @model)
|
22
|
+
configure_basic_settings(@config, @vm, @model)
|
23
|
+
configure_networking(@config, @vm, @model)
|
24
|
+
if @model.protocol == "ssh"
|
25
|
+
add_inline_shell_provisioner(hosts_file(@models, "linux"),"hosts_file")
|
26
|
+
else
|
27
|
+
add_inline_shell_provisioner(hosts_file(@models, "windows"),"hosts_file")
|
28
|
+
end
|
29
|
+
add_inline_shell_provisioner(facter_overrides(@model.custom_facts, "linux"), 'facter_overrides') if @model.custom_facts
|
30
|
+
end
|
31
|
+
|
32
|
+
# Return a shell command that ensures that all vagrant hosts are in /etc/hosts
|
33
|
+
def hosts_file(vms, ostype)
|
34
|
+
if ostype == "linux"
|
35
|
+
commands = "sed -i -e /127.0.*.1.*/d /etc/hosts;"
|
36
|
+
vms.each do |vm|
|
37
|
+
hostname = vm.hostname
|
38
|
+
domain = vm.domain_name
|
39
|
+
fqdn = "#{hostname}.#{domain}"
|
40
|
+
if vm.ipaddress
|
41
|
+
commands << "grep -q #{fqdn} /etc/hosts || " \
|
42
|
+
"echo #{vm.ipaddress} #{fqdn} #{hostname} " \
|
43
|
+
">> /etc/hosts;"
|
44
|
+
end
|
45
|
+
vm.additional_hosts&.each do |host|
|
46
|
+
fqdn = "#{host.name}.#{host.domain_name}"
|
47
|
+
commands << "grep -q #{fqdn} /etc/hosts || " \
|
48
|
+
"echo #{host.ip} #{fqdn} #{host.name} " \
|
49
|
+
">> /etc/hosts;"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
commands << "echo 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 >> /etc/hosts"
|
53
|
+
else
|
54
|
+
commands = 'puppet apply c:\vagrant\windows_hosts_file.pp'
|
55
|
+
win_hosts = ""
|
56
|
+
vms.each do |vm|
|
57
|
+
hostname = vm.hostname
|
58
|
+
domain = vm.domain_name
|
59
|
+
fqdn = "#{hostname}.#{domain}"
|
60
|
+
win_hosts << "host { '#{fqdn}': ip => '#{vm.ipaddress}', host_aliases => '#{hostname}' }\n" if vm.ipaddress
|
61
|
+
vm.additional_hosts&.each do |host|
|
62
|
+
fqdn = "#{host.name}.#{host.domain_name}"
|
63
|
+
win_hosts << "host { '#{fqdn}': ip => '#{host.ip}', host_aliases => '#{host.name}' }\n"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
win_hosts = win_hosts.split("\n").uniq.join("\n")
|
67
|
+
File.write(File.join(Dir.pwd, "windows_hosts_file.pp"), win_hosts)
|
68
|
+
end
|
69
|
+
commands
|
70
|
+
end
|
71
|
+
|
72
|
+
def add_inline_shell_provisioner(command, name=nil, env = nil)
|
73
|
+
provisioner = {shell: {inline: command}}
|
74
|
+
provisioner[:shell][:env] = env if env
|
75
|
+
provisioner[:shell][:name] = name if name
|
76
|
+
@provisioners << provisioner
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_shell_script_provisioner(script_name, parameters = [], env = nil)
|
80
|
+
script_path = File.join(@root_path, script_name)
|
81
|
+
provisioner = {shell: {path: script_path, name: script_name, args: parameters}}
|
82
|
+
provisioner[:shell][:env] = env if env
|
83
|
+
@provisioners << provisioner
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_puppet_provisioner(manifests_path, manifest_file, options)
|
87
|
+
@provisioners << {puppet: {manifests_path: manifests_path, manifest_file: manifest_file, options: options}}
|
88
|
+
end
|
89
|
+
|
90
|
+
def environment_variables
|
91
|
+
env = {}
|
92
|
+
env.merge! { "CI_TOKEN" => ENV["CI_JOB_TOKEN"] } if ENV["CI_JOB_TOKEN"]
|
93
|
+
env
|
94
|
+
end
|
95
|
+
|
96
|
+
def facter_overrides(facts, ostype)
|
97
|
+
if ostype == "linux"
|
98
|
+
facter_overrides = facts.map { |key, value| "export FACTER_#{key}=\\\"#{value}\\\"" }.join('\n')
|
99
|
+
'echo -e "' + facter_overrides + '" > /etc/profile.d/facter_overrides.sh'
|
100
|
+
else
|
101
|
+
facter_overrides = facts.map { |key, value| "Write-Host #{key}=#{value}" }.join("`r")
|
102
|
+
'echo "' + facter_overrides + '" > C:\ProgramData\PuppetLabs\facter\facts.d\facter_overrides.ps1'
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Configure VirtualBox disks attached to the virtual machine
|
107
|
+
def configure_disks(vb, model)
|
108
|
+
vminfo = vm_info(model.name)
|
109
|
+
disks = model.disks || {}
|
110
|
+
unless /Storage Controller Name \(1\): *SATA Controller/.match?(vminfo)
|
111
|
+
# puts "Attaching SATA Controller"
|
112
|
+
vb.customize [
|
113
|
+
"storagectl", :id,
|
114
|
+
"--name", "SATA Controller",
|
115
|
+
"--add", "sata",
|
116
|
+
"--portcount", disks.size
|
117
|
+
]
|
118
|
+
# else
|
119
|
+
# puts 'SATA Controller already attached'
|
120
|
+
end
|
121
|
+
|
122
|
+
disks.each_with_index do |disk, i|
|
123
|
+
disk_name = disk.name
|
124
|
+
disk_size = disk.size
|
125
|
+
disk_uuid = disk.uuid
|
126
|
+
real_uuid = "00000000-0000-0000-0000-#{disk_uuid.rjust(12, "0")}"
|
127
|
+
disk_filename = if model.cluster
|
128
|
+
File.join(Dir.pwd, "#{disk_name}_#{model.cluster}.vdi")
|
129
|
+
else
|
130
|
+
File.join(Dir.pwd, "#{disk_name}.vdi")
|
131
|
+
end
|
132
|
+
|
133
|
+
if File.file?(disk_filename)
|
134
|
+
# puts "Disk #{disk_filename} already created"
|
135
|
+
disk_hash = `VBoxManage showmediuminfo "#{disk_filename}"`.scan(/(.*): *(.*)/).to_h
|
136
|
+
current_uuid = disk_hash["UUID"]
|
137
|
+
else
|
138
|
+
# puts "Creating disk #{disk_filename}"
|
139
|
+
current_uuid = "0"
|
140
|
+
if model.cluster
|
141
|
+
vb.customize [
|
142
|
+
"createhd",
|
143
|
+
"--filename", disk_filename,
|
144
|
+
"--size", disk_size.to_s,
|
145
|
+
"--variant", "Fixed"
|
146
|
+
]
|
147
|
+
vb.customize [
|
148
|
+
"modifyhd", disk_filename,
|
149
|
+
"--type", "shareable"
|
150
|
+
]
|
151
|
+
else
|
152
|
+
vb.customize [
|
153
|
+
"createhd",
|
154
|
+
"--filename", disk_filename,
|
155
|
+
"--size", disk_size.to_s,
|
156
|
+
"--variant", "Standard"
|
157
|
+
]
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
# Conditional for adding disk_uuid
|
162
|
+
if model.cluster && current_uuid == real_uuid
|
163
|
+
# puts "Attaching shareable disk #{disk_filename}"
|
164
|
+
vb.customize [
|
165
|
+
"storageattach", :id,
|
166
|
+
"--storagectl", "SATA Controller",
|
167
|
+
"--port", (i + 1).to_s,
|
168
|
+
"--device", 0,
|
169
|
+
"--type", "hdd",
|
170
|
+
"--medium", disk_filename,
|
171
|
+
"--mtype", "shareable"
|
172
|
+
]
|
173
|
+
elsif model.cluster
|
174
|
+
# puts "Attaching shareable disk #{disk_filename}, adding UUID #{real_uuid}"
|
175
|
+
vb.customize [
|
176
|
+
"storageattach", :id,
|
177
|
+
"--storagectl", "SATA Controller",
|
178
|
+
"--port", (i + 1).to_s,
|
179
|
+
"--device", 0,
|
180
|
+
"--type", "hdd",
|
181
|
+
"--medium", disk_filename,
|
182
|
+
"--mtype", "shareable",
|
183
|
+
"--setuuid", real_uuid
|
184
|
+
]
|
185
|
+
elsif current_uuid == real_uuid
|
186
|
+
# puts "Attaching normal disk #{disk_filename}"
|
187
|
+
vb.customize [
|
188
|
+
"storageattach", :id,
|
189
|
+
"--storagectl", "SATA Controller",
|
190
|
+
"--port", (i + 1).to_s,
|
191
|
+
"--device", 0,
|
192
|
+
"--type", "hdd",
|
193
|
+
"--medium", disk_filename
|
194
|
+
]
|
195
|
+
else
|
196
|
+
# puts "Attaching normal disk #{disk_filename}, adding UUID #{real_uuid}"
|
197
|
+
vb.customize [
|
198
|
+
"storageattach", :id,
|
199
|
+
"--storagectl", "SATA Controller",
|
200
|
+
"--port", (i + 1).to_s,
|
201
|
+
"--device", 0,
|
202
|
+
"--type", "hdd",
|
203
|
+
"--medium", disk_filename,
|
204
|
+
"--setuuid", real_uuid
|
205
|
+
]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def configure_plugins(config, vm, model)
|
211
|
+
model.required_plugins&.each { |name| plugin_check(name) }
|
212
|
+
end
|
213
|
+
|
214
|
+
def configure_software_files(config, vm, model)
|
215
|
+
local_software_file_check(vm, model.software_files) if model.software_files
|
216
|
+
local_software_file_check(vm, [model.puppet_installer]) if model.puppet_installer
|
217
|
+
end
|
218
|
+
|
219
|
+
def configure_dhcp_fix(config, vm, model)
|
220
|
+
if model.dhcp_fix
|
221
|
+
vm.trigger.before :up do |trigger|
|
222
|
+
if Gem.win_platform?
|
223
|
+
trigger.info = "DHCP fix process doesn't work on Windows..."
|
224
|
+
else
|
225
|
+
trigger.info = "Starting DHCP fix process..."
|
226
|
+
trigger.run = {inline: "sh -c \"until vboxmanage guestcontrol #{name} run \"/usr/bin/sudo\" --username vagrant --password vagrant --verbose --wait-stdout dhclient; do c=$((${c:-1}+1)); test $c -gt 50 && exit; sleep 20; done > /dev/null 2>&1 &\""}
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
def configure_basic_settings(config, vm, model)
|
233
|
+
vm.vm.communicator = model.protocol || "ssh"
|
234
|
+
vm.vm.box = model.box
|
235
|
+
|
236
|
+
if model.protocol == "ssh"
|
237
|
+
vm.vm.hostname = "#{model.hostname}.#{model.domain_name}"
|
238
|
+
config.ssh.forward_agent = true
|
239
|
+
config.ssh.forward_x11 = true
|
240
|
+
else
|
241
|
+
vm.vm.hostname = model.hostname
|
242
|
+
config.winrm.ssl_peer_verification = false
|
243
|
+
config.winrm.retry_delay = 60
|
244
|
+
config.winrm.username = "Administrator"
|
245
|
+
config.winrm.password = "vagrant"
|
246
|
+
# config.winrm.retry_limit = 10
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def configure_networking(config, vm, model)
|
251
|
+
vm.vm.network "private_network", ip: model.ipaddress
|
252
|
+
vm.vm.network "private_network", ip: model.private_ip, virtualbox__intnet: true if model.private_ip
|
253
|
+
end
|
254
|
+
|
255
|
+
def configure_synced_folders(config, vm, model, user_id = nil, group_id = nil)
|
256
|
+
vm.vm.synced_folder "", "/vagrant", type: :virtualbox, owner: user_id, group: group_id
|
257
|
+
end
|
258
|
+
|
259
|
+
def configure_code_folder(config, vm, model, user_id = nil, group_id = nil)
|
260
|
+
module_path = File.expand_path("..", __FILE__) + "/../../../../../code/environments/plugin"
|
261
|
+
vm.vm.synced_folder module_path, "/etc/puppetlabs/code/environments/plugin", type: :virtualbox, owner: user_id, group: group_id
|
262
|
+
end
|
263
|
+
|
264
|
+
|
265
|
+
def configure_vm(vm, model)
|
266
|
+
vm.vm.provider :virtualbox do |vb|
|
267
|
+
vb.cpus = model.cpucount || 1
|
268
|
+
vb.memory = model.ram || 4096
|
269
|
+
vb.name = model.vmname
|
270
|
+
vb.auto_nat_dns_proxy = false
|
271
|
+
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
|
272
|
+
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
|
273
|
+
|
274
|
+
virtualboxorafix(vb) if model.virtualboxorafix
|
275
|
+
|
276
|
+
configure_disks(vb, model) if model.needs_storage
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def plugin_check(plugin_name)
|
281
|
+
unless Vagrant.has_plugin?(plugin_name)
|
282
|
+
raise "#{plugin_name} is not installed, please run: vagrant plugin " \
|
283
|
+
"install #{plugin_name}"
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
def vbox_manage?
|
288
|
+
@vbox_manage ||= !`which VBoxManage`.chomp.empty?
|
289
|
+
end
|
290
|
+
|
291
|
+
def vm_boxes
|
292
|
+
boxes = {}
|
293
|
+
if vbox_manage?
|
294
|
+
vms = `VBoxManage list vms`
|
295
|
+
vms.split("\n").each do |vm|
|
296
|
+
x = vm.split
|
297
|
+
k = x[0].delete('"') # vm name
|
298
|
+
v = x[1].gsub(/[{}]/, "") # vm UUID
|
299
|
+
boxes[k] = v
|
300
|
+
end
|
301
|
+
end
|
302
|
+
boxes
|
303
|
+
end
|
304
|
+
|
305
|
+
def vm_exists?(vmname)
|
306
|
+
vm_boxes[vmname] ? true : false
|
307
|
+
end
|
308
|
+
|
309
|
+
def vm_info(vmname)
|
310
|
+
vm_exists?(vmname) ? `VBoxManage showvminfo #{vmname}` : ""
|
311
|
+
end
|
312
|
+
|
313
|
+
def local_software_file_check(srv, file_names)
|
314
|
+
srv.trigger.before [:up, :reload, :provision] do |trigger|
|
315
|
+
trigger.ruby do |env, machine|
|
316
|
+
files_found = true
|
317
|
+
file_names.each do |file_name|
|
318
|
+
file_path = "#{Dir.pwd}/modules/software/files/#{file_name}"
|
319
|
+
unless File.exist?(file_path) # returns true for directories
|
320
|
+
files_found = false
|
321
|
+
env.ui.error "Missing software file: #{file_name}"
|
322
|
+
end
|
323
|
+
end
|
324
|
+
if !files_found
|
325
|
+
env.ui.error "Please add missing file(s) to the: ./modules/software/files/ directory."
|
326
|
+
raise FilesNotFoundError
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module EM
|
3
|
+
class Masterless < Base
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
if @model.protocol == "ssh"
|
7
|
+
setup_linux
|
8
|
+
else
|
9
|
+
setup_windows
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def setup_linux
|
16
|
+
configure_synced_folders(@config, @vm, @model, @model.mount_uid, @model.mount_gid)
|
17
|
+
add_shell_script_provisioner("install_puppet.sh")
|
18
|
+
add_shell_script_provisioner("setup_puppet.sh", [], environment_variables)
|
19
|
+
add_puppet_provisioner(["vm", "/vagrant/manifests"], "site.pp", "--test")
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_windows
|
23
|
+
add_shell_script_provisioner(facter_overrides(@model.custom_facts, "windows"), "always") if @model.custom_facts
|
24
|
+
add_shell_script_provisioner(hosts_file(@models, "windows"))
|
25
|
+
add_shell_script_provisioner(%(Set-ExecutionPolicy Bypass -Scope Process -Force
|
26
|
+
cd c:\\vagrant\\vm-scripts
|
27
|
+
.\\install_puppet.ps1
|
28
|
+
cd c:\\vagrant\\vm-scripts
|
29
|
+
.\\setup_puppet.ps1
|
30
|
+
iex "& 'C:\\Program Files\\Puppet Labs\\Puppet\\bin\\puppet' resource service puppet ensure=stopped"))
|
31
|
+
add_puppet_provisioner(["vm", "c:\\vagrant\\manifests"], "site.pp", "--test")
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns a shell command that sets the custom facts
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module EM
|
3
|
+
class PeAgent < Base
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
if @model.protocol == "ssh"
|
7
|
+
setup_linux
|
8
|
+
else
|
9
|
+
setup_windows
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def setup_linux
|
16
|
+
add_shell_script_provisioner("install_puppet_agent.sh", ["#{@model.puppet_master}.#{@model.domain_name}"], environment_variables)
|
17
|
+
@provisioners << {shell: {inline: 'systemctl stop puppet; pkill -9 -f "puppet.*agent.*"; true'}}
|
18
|
+
@provisioners << {puppet_server: {puppet_server: "#{@model.puppet_master}.#{@model.domain_name}", puppet_node: "#{@model.hostname}.#{@model.domain_name}", options: "--test"}}
|
19
|
+
@provisioners << {shell: {inline: "systemctl start puppet"}}
|
20
|
+
end
|
21
|
+
|
22
|
+
def setup_windows
|
23
|
+
# @provisioners << { shell: { inline: %Q(Set-ExecutionPolicy Bypass -Scope Process -Force
|
24
|
+
# [Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
|
25
|
+
# $webClient = New-Object System.Net.WebClient
|
26
|
+
# $webClient.DownloadFile('https://#{@model.puppet_master}.#{@model.domain_name'}:8140/packages/current/install.ps1', 'install.ps1')
|
27
|
+
# .\\install.ps1
|
28
|
+
# iex 'puppet resource service puppet ensure=stopped') } }
|
29
|
+
# @provisioners << { puppet_server: { puppet_server: "#{@model.puppet_master}.#{@model.domain_name}", puppet_node: "#{@model.hostname}.#{@model.domain_name'}", options: "--test" } }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module EM
|
3
|
+
class PeMaster < Base
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
configure_synced_folders(@config, @vm, @model, @model.mount_uid, @model.mount_gid)
|
7
|
+
|
8
|
+
add_shell_script_provisioner("install_puppet_enterprise.sh", [@model.puppet_installer, @model.domain_name])
|
9
|
+
@provisioners << {puppet_server: {puppet_server: "#{@model.puppet_master}.#{@model.domain_name}", options: "--test --environment plugin"}}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Vagrant
|
2
|
+
module EM
|
3
|
+
class PsServer < Base
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
configure_synced_folders(@config, @vm, @model, @model.mount_uid, @model.mount_gid)
|
7
|
+
configure_code_folder(@config, @vm, @model, @model.mount_uid, @model.mount_gid)
|
8
|
+
|
9
|
+
add_shell_script_provisioner("install_puppet.sh")
|
10
|
+
add_shell_script_provisioner("setup_puppet.sh", [], environment_variables)
|
11
|
+
add_shell_script_provisioner("install_puppet_server.sh", [@model.domain_name], environment_variables)
|
12
|
+
@provisioners << {puppet_server: {puppet_server: "#{@model.puppet_master}.#{@model.domain_name}", options: "--test --environment plugin"}}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
if ([System.IO.File]::Exists("$Env:LOCALAPPDATA\install_modules.done")) {
|
2
|
+
Write-Output "Modules already installed"
|
3
|
+
} else {
|
4
|
+
Write-Output 'Installing required puppet modules...'
|
5
|
+
Set-Location 'c:\vagrant'
|
6
|
+
Invoke-Expression "& 'c:\Program Files\Puppet Labs\Puppet\puppet\bin\r10k.bat' puppetfile install --verbose"
|
7
|
+
Write-Output 'Installing required puppet modules finished.'
|
8
|
+
New-Item -ItemType file $Env:LOCALAPPDATA\install_modules.done
|
9
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
if ([System.IO.File]::Exists("$Env:LOCALAPPDATA\install_puppet.done")) {
|
2
|
+
Write-Output "Puppet already installed"
|
3
|
+
} else {
|
4
|
+
Write-Output 'Disable Security scanning...'
|
5
|
+
Set-MpPreference -DisableArchiveScanning $true -DisableRealtimeMonitoring $true
|
6
|
+
$uri = "https://downloads.puppetlabs.com/windows/puppet8/puppet-agent-x64-latest.msi"
|
7
|
+
$out = "c:\windows\temp\puppet-agent-x64-latest.msi"
|
8
|
+
Write-Output 'Downloading Puppet Agent...'
|
9
|
+
Invoke-WebRequest -Uri $uri -OutFile $out
|
10
|
+
Write-Output 'Installing Puppet Agent...'
|
11
|
+
Start-Process C:\Windows\System32\msiexec.exe -ArgumentList "/qn /norestart /i $out" -wait
|
12
|
+
Write-Output 'Puppet installed'
|
13
|
+
Write-Output 'Installing Chocolatey'
|
14
|
+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
|
15
|
+
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
|
16
|
+
Write-Output 'Chocolatey installed'
|
17
|
+
Write-Output 'Installing git'
|
18
|
+
$env:PATH += ';C:\ProgramData\chocolatey'
|
19
|
+
Invoke-Expression "& choco install git -y --no-progress"
|
20
|
+
Write-Output 'git installed'
|
21
|
+
New-Item -ItemType file $Env:LOCALAPPDATA\install_puppet.done
|
22
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
if [ -f /var/log/install_puppet.done ]
|
2
|
+
then
|
3
|
+
echo "Puppet already installed"
|
4
|
+
else
|
5
|
+
#
|
6
|
+
# Install correct puppet version
|
7
|
+
#
|
8
|
+
if [ -f "/vagrant/puppet_version" ]; then
|
9
|
+
PACKAGE="puppet-agent-$(cat /vagrant/puppet_version)"
|
10
|
+
else
|
11
|
+
PACKAGE="puppet-agent"
|
12
|
+
fi
|
13
|
+
echo "Installing $PACKAGE"
|
14
|
+
rhel=$(awk -F: '{print $5}' /etc/system-release-cpe)
|
15
|
+
yum install -y --nogpgcheck https://yum.puppetlabs.com/puppet8-release-el-${rhel}.noarch.rpm > /dev/null
|
16
|
+
# yum install -y --nogpgcheck https://yum.puppetlabs.com/puppet7-release-el-${rhel}.noarch.rpm > /dev/null
|
17
|
+
yum install -y --nogpgcheck $PACKAGE
|
18
|
+
rpm -q git || yum install -y --nogpgcheck git
|
19
|
+
|
20
|
+
touch /var/log/install_puppet.done
|
21
|
+
fi
|
@@ -0,0 +1,17 @@
|
|
1
|
+
puppet_server=${1}
|
2
|
+
if [ -f /var/log/install_puppet_agent.done ]
|
3
|
+
then
|
4
|
+
echo "Puppet agent already installed"
|
5
|
+
else
|
6
|
+
#
|
7
|
+
# Install puppet agent
|
8
|
+
#
|
9
|
+
curl -k https://${puppet_server}:8140/packages/current/install.bash | sudo bash
|
10
|
+
|
11
|
+
#
|
12
|
+
# Increase runtimeout from default of 1h
|
13
|
+
#
|
14
|
+
echo "runtimeout = 57600" >> /etc/puppetlabs/puppet/puppet.conf
|
15
|
+
|
16
|
+
touch /var/log/install_puppet_agent.done
|
17
|
+
fi
|
@@ -0,0 +1,42 @@
|
|
1
|
+
puppet_installer=${1}
|
2
|
+
domain_name=${2}
|
3
|
+
if [ -f /var/log/install_puppet_server.done ]
|
4
|
+
then
|
5
|
+
echo "Puppet server already installed"
|
6
|
+
else
|
7
|
+
#
|
8
|
+
# Install puppet server
|
9
|
+
#
|
10
|
+
/vagrant/modules/software/files/${puppet_installer} -c /vagrant/pe.conf -y
|
11
|
+
|
12
|
+
#
|
13
|
+
# For this vagrant setup, we make sure all nodes in the domain examples.com are autosigned. In production
|
14
|
+
# you'dd want to explicitly confirm every node.
|
15
|
+
#
|
16
|
+
echo "*.${domain_name}" > /etc/puppetlabs/puppet/autosign.conf
|
17
|
+
echo "*.local" >> /etc/puppetlabs/puppet/autosign.conf
|
18
|
+
echo "*.home" >> /etc/puppetlabs/puppet/autosign.conf
|
19
|
+
|
20
|
+
#
|
21
|
+
# For now we stop the firewall. In the future we will add a nice puppet setup to the ports needed
|
22
|
+
# for Puppet Enterprise to work correctly.
|
23
|
+
#
|
24
|
+
if systemctl list-units --type=service --all | grep -q "firewalld.service"; then
|
25
|
+
systemctl stop firewalld.service
|
26
|
+
systemctl disable firewalld.service
|
27
|
+
fi
|
28
|
+
|
29
|
+
#
|
30
|
+
# This script make's sure the vagrant paths's are symlinked to the places Puppet Enterprise looks for specific
|
31
|
+
# modules, manifests and hiera data. This makes it easy to change these files on your host operating system.
|
32
|
+
#
|
33
|
+
bash /vagrant/vm-scripts/setup_puppet.sh
|
34
|
+
|
35
|
+
#
|
36
|
+
# Make sure all plugins are synced to the puppetserver before exiting and stating
|
37
|
+
# any agents
|
38
|
+
#
|
39
|
+
systemctl restart pe-puppetserver
|
40
|
+
|
41
|
+
touch /var/log/install_puppet_server.done
|
42
|
+
fi
|
@@ -0,0 +1,37 @@
|
|
1
|
+
domain_name=${1}
|
2
|
+
if [ -f /var/log/install_puppet_server.done ]
|
3
|
+
then
|
4
|
+
echo "Puppet server already installed"
|
5
|
+
else
|
6
|
+
yum install puppetserver -y
|
7
|
+
#
|
8
|
+
# For this vagrant setup, we make sure all nodes in the domain examples.com are autosigned. In production
|
9
|
+
# you'dd want to explicitly confirm every node.
|
10
|
+
#
|
11
|
+
echo "*.${domain_name}" > /etc/puppetlabs/puppet/autosign.conf
|
12
|
+
echo "*.local" >> /etc/puppetlabs/puppet/autosign.conf
|
13
|
+
echo "*.home" >> /etc/puppetlabs/puppet/autosign.conf
|
14
|
+
#
|
15
|
+
# Install the modules
|
16
|
+
#
|
17
|
+
puppet module install puppetlabs-stdlib --environment plugin
|
18
|
+
puppet module install saz-timezone --environment plugin
|
19
|
+
puppet module install puppetlabs-puppetdb --environment plugin
|
20
|
+
puppet module install ipcrm-echo --environment plugin
|
21
|
+
#
|
22
|
+
# For now we stop the firewall. In the future we will add a nice puppet setup to the ports needed
|
23
|
+
# for Puppet Enterprise to work correctly.
|
24
|
+
#
|
25
|
+
if systemctl list-units --type=service --all | grep -q "firewalld.service"; then
|
26
|
+
systemctl stop firewalld.service
|
27
|
+
systemctl disable firewalld.service
|
28
|
+
fi
|
29
|
+
|
30
|
+
#
|
31
|
+
# Make sure all plugins are synced to the puppetserver before exiting and stating
|
32
|
+
# any agents
|
33
|
+
#
|
34
|
+
systemctl restart puppetserver
|
35
|
+
|
36
|
+
touch /var/log/install_puppet_server.done
|
37
|
+
fi
|