puppet-runner 0.0.19 → 0.0.20
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 +4 -4
- data/bin/puppet-runner +37 -8
- data/puppet-runner.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ef7b7a722f72764a0d2b013624442fbf1a953a78f9ccd380d718209f53acf61
|
4
|
+
data.tar.gz: c060b7c2a5d188de60cda6afc41f9beb6e1693aed4966d609396596cbbdf6c57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67de10395d2f7c802a5b00e8c0a15b2149a33514b1cbda0a811cdd34d97a108b5b343b142386918e6aa957ead50fcc0ffe38bc503a56d877bfd89d85faa243af
|
7
|
+
data.tar.gz: 864c05e7c5b9223d01fc09e1b43ae2925904542128b5ecd81310c60167706918a1768a833679f10fb545cb27850335f803c32fa5b49c282fc71588d679153be2
|
data/bin/puppet-runner
CHANGED
@@ -27,7 +27,7 @@ doc = <<DOCOPT
|
|
27
27
|
Adaptavist puppet runner
|
28
28
|
|
29
29
|
Usage:
|
30
|
-
puppet-runner (prepare|all) [-c CONFIG_DIR] [-t TEMPLATES] [-d DESTINATION_DIR] [-f FACTS_DEST] [-s SERVERNAME] [-p PUPPET_APPLY] [-r PUPPETFILE_CONFIG] [-o PUPPETFILE_OUTPUT_PATH] [-e EYAML_KEY_PATH]
|
30
|
+
puppet-runner (prepare|all) [-c CONFIG_DIR] [-t TEMPLATES] [-d DESTINATION_DIR] [-f FACTS_DEST] [-s SERVERNAME] [-p PUPPET_APPLY] [-r PUPPETFILE_CONFIG] [-o PUPPETFILE_OUTPUT_PATH] [-e EYAML_KEY_PATH] [-k]
|
31
31
|
puppet-runner start [-p PUPPET_APPLY]
|
32
32
|
puppet-runner -h | --help
|
33
33
|
|
@@ -42,6 +42,7 @@ Options:
|
|
42
42
|
-r PUPPETFILE_CONFIG --puppetfile_config puppetfile_config Puppetfile composition config file
|
43
43
|
-o PUPPETFILE_OUTPUT_PATH --puppetfile_output_path PUPPETFILE_OUTPUT_PATH Result Puppetfile path
|
44
44
|
-e EYAML_KEY_PATH --eyaml_key_path EYAML_KEY_PATH Path to eyaml encryption key pair
|
45
|
+
-k --keep-facts Flag to keep the encrypted facts file in /tmp for analysis
|
45
46
|
Commands:
|
46
47
|
all Runs the following commands prepare, start
|
47
48
|
start Runs puppet apply
|
@@ -119,6 +120,7 @@ rescue Docopt::Exit => e
|
|
119
120
|
end
|
120
121
|
|
121
122
|
stop_apply = false
|
123
|
+
keep_facts = false
|
122
124
|
|
123
125
|
if options['all'] || options['prepare']
|
124
126
|
input_dir = options["--config_dir"] || options["-c"]
|
@@ -130,6 +132,7 @@ if options['all'] || options['prepare']
|
|
130
132
|
eyaml_key_path = options["--eyaml_key_path"] || options["-e"] || "/etc/puppet/config"
|
131
133
|
hostname = options["--servername"] || options["-s"] || Facter.value("hostname")
|
132
134
|
puts "Hostname #{hostname}"
|
135
|
+
keep_facts = true if options["-k"] or options["--keep-facts"]
|
133
136
|
|
134
137
|
config_file_path = path_join_glob(input_dir, hostname+".yaml")
|
135
138
|
templates_dir = path_join_glob(templates, "templates")
|
@@ -278,6 +281,10 @@ if options['all'] || options['prepare']
|
|
278
281
|
end
|
279
282
|
custom_facts_path = path_join_glob(input_dir, "#{hostname}_facts.yaml")
|
280
283
|
custom_facts = YAML.load_file(custom_facts_path) || {}
|
284
|
+
|
285
|
+
# add a fact for the localtion of facter
|
286
|
+
custom_facts['facter_file_location'] = output_facts_file_path
|
287
|
+
|
281
288
|
File.open(output_encrypted_facts_file_path, 'w+') do |output_file|
|
282
289
|
output_result_default_facts = result_default_facts.deep_merge!(custom_facts, {:merge_hash_arrays => true}).to_yaml
|
283
290
|
prefixed_facts_comments.each do |pattern, replacement|
|
@@ -285,6 +292,7 @@ if options['all'] || options['prepare']
|
|
285
292
|
output_result_default_facts.gsub!(/^#{pattern}/, "\##{replacement}\n#{pattern}")
|
286
293
|
end
|
287
294
|
end
|
295
|
+
|
288
296
|
output_file.write(output_result_default_facts)
|
289
297
|
|
290
298
|
# now that the merged final facts are present look for any global transformations to apply
|
@@ -351,13 +359,20 @@ if options['all'] || options['prepare']
|
|
351
359
|
end
|
352
360
|
}
|
353
361
|
end
|
362
|
+
|
354
363
|
output_file.write(decrypted.join)
|
355
364
|
end
|
356
365
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
366
|
+
# unless asked not to, attempt to remove the encrypted facts file
|
367
|
+
if keep_facts
|
368
|
+
debug "Removal of tmp encrypted facts file #{output_encrypted_facts_file_path} skipped at users request"
|
369
|
+
else
|
370
|
+
debug "Attempting to remove tmp encrypted facts file #{output_encrypted_facts_file_path}"
|
371
|
+
begin
|
372
|
+
FileUtils.rm output_encrypted_facts_file_path
|
373
|
+
rescue
|
374
|
+
warning "Unable to remove tmp encrypted facts file #{output_encrypted_facts_file_path}"
|
375
|
+
end
|
361
376
|
end
|
362
377
|
|
363
378
|
# create puppetfile from the dictionary
|
@@ -396,7 +411,7 @@ if options['all'] || options['prepare']
|
|
396
411
|
end
|
397
412
|
|
398
413
|
|
399
|
-
# start puppet
|
414
|
+
# start puppet
|
400
415
|
if (options['start'] || options['all']) && !stop_apply
|
401
416
|
require 'puppet'
|
402
417
|
modulefile_definition = Gem::Version.new(Puppet.version) > Gem::Version.new('4.0.0') ? '--modulepath /etc/puppet/modules' : ''
|
@@ -405,9 +420,23 @@ if (options['start'] || options['all']) && !stop_apply
|
|
405
420
|
debug "Running #{to_execute}"
|
406
421
|
`#{to_execute}`
|
407
422
|
exit_code = $?.exitstatus
|
423
|
+
|
424
|
+
# attempt to remove the fact file as its unencrypted (we do not care about exit status)
|
425
|
+
fact_file_location = Facter.value("facter_file_location")
|
426
|
+
if fact_file_location
|
427
|
+
if File.file?(fact_file_location)
|
428
|
+
debug "Attempting to remove fact file #{fact_file_location}"
|
429
|
+
begin
|
430
|
+
FileUtils.rm fact_file_location
|
431
|
+
rescue
|
432
|
+
warning "Unable to remove facts file #{fact_file_location}.\nPlease urgently remove this as it holds unencrypted values"
|
433
|
+
end
|
434
|
+
end
|
435
|
+
else
|
436
|
+
warning "Unable to locate Facts file, please urgently locate and remove this as it holds unencrypted values"
|
437
|
+
end
|
438
|
+
|
408
439
|
if exit_code != 2
|
409
440
|
raise "execute_puppet exit status: #{exit_code}"
|
410
441
|
end
|
411
442
|
end
|
412
|
-
|
413
|
-
|
data/puppet-runner.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "puppet-runner"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.20"
|
8
8
|
spec.authors = ["Martin Brehovsky", "Matthew Hope"]
|
9
9
|
spec.email = ["mbrehovsky@adaptavist.com"]
|
10
10
|
spec.summary = %q{Preprocessor for hiera config}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-runner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Brehovsky
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|