puppet-runner 0.0.21 → 0.0.25
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/README.md +6 -1
- data/bin/puppet-runner +50 -7
- data/puppet-runner.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c99b584c8b2e9bb6b81e8d8d2f1f9d28c693450fce0bef5fde9e54438a3cde5e
|
4
|
+
data.tar.gz: cc2d7f9e9aa0fa5469e8b4972f21cb8a82327260fa313dd103dcaff9c2884add
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 327eafe7227662b5d00ddcc2d34d0fa72c8d3f44f69c01f92139293651ea707f9b9d2565ab69ed7642be49ff34c2908807f66dbebf1fdcf480cdba047735f5a6
|
7
|
+
data.tar.gz: a6d3c97286d790c3336e123dd53a55672b2c1afcf42805d016ed76fed4b13ef935c5d7b4bced1d3916eb228254cbc38598cba1e36ce715d19d783ef72b776d56
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ Executable gem that composes hiera configuration and facts and execute puppet ap
|
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
11
|
-
* puppet-runner (prepare|all) [-c CONFIG_DIR] [-t TEMPLATES] [-d DESTINATION_DIR] [-f FACTS_DEST] [-s SERVERNAME] [-r PUPPETFILE_CONFIG] [-o PUPPETFILE_OUTPUT_PATH] [-e EYAML_KEY_PATH]
|
11
|
+
* puppet-runner (prepare|all) [-c CONFIG_DIR] [-t TEMPLATES] [-d DESTINATION_DIR] [-f FACTS_DEST] [-s SERVERNAME] [-r PUPPETFILE_CONFIG] [-o PUPPETFILE_OUTPUT_PATH] [-e EYAML_KEY_PATH] [-x CUSTOM_FACTS_DIR]
|
12
12
|
* puppet-runner start [-p PUPPET_APPLY]
|
13
13
|
* puppet-runner -h | --help
|
14
14
|
|
@@ -416,11 +416,16 @@ Path to output Puppetfile.
|
|
416
416
|
* -d DESTINATION_DIR --dest_dir DESTINATION_DIR Directory for result hiera config.
|
417
417
|
* -t TEMPLATES --templates TEMPLATES Directory containing templates and defaults folder with functionality templates and default facts
|
418
418
|
* -f FACTS_DEST --facts_dest_dir FACTS_DEST Destination directory to store result facts
|
419
|
+
* -x CUSTOM_FACTS_DIR --custom_facts_dir CUSTOM_FACTS_DIR Directory containing yaml files with custom facts that will be merged with ones from <hostname>_facts.yaml, custom facts can overwrite them
|
419
420
|
* -r PUPPETFILE_CONFIG --puppetfile_config puppetfile_config Puppetfile composition config file
|
420
421
|
* -o PUPPETFILE_OUTPUT_PATH --puppetfile_output_path PUPPETFILE_OUTPUT_PATH Result Puppetfile path
|
421
422
|
* -e EYAML_KEY_PATH --eyaml_key_pair EYAML_KEY_PATH Path to eyaml encryption key pair
|
422
423
|
* -p PUPPET_APPLY --puppet_apply PUPPET_APPLY Custom puppet apply command to run
|
423
424
|
* -k --keep-facts Flag to keep the encrypted facts file in /tmp for analysis
|
425
|
+
* -n --dry-run Flag to indicate puppet should run in dry run mode (--noop), this also sets the verbose flag to true
|
426
|
+
* -v --verbose Flag to indicate that all output from puppet apply should be displayed instead of just stdout
|
427
|
+
Commands:
|
428
|
+
|
424
429
|
|
425
430
|
Commands:
|
426
431
|
|
data/bin/puppet-runner
CHANGED
@@ -27,8 +27,8 @@ 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] [-k]
|
31
|
-
puppet-runner start [-p PUPPET_APPLY]
|
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] [-m MODULE_PATH] [-x CUSTOM_FACTS_DIR] [-k] [-n] [-v]
|
31
|
+
puppet-runner start [-p PUPPET_APPLY] [-m MODULE_PATH] [-n] [-v]
|
32
32
|
puppet-runner -h | --help
|
33
33
|
|
34
34
|
Options:
|
@@ -38,11 +38,15 @@ Options:
|
|
38
38
|
-d DESTINATION_DIR --dest_dir DESTINATION_DIR Directory for result hiera config.
|
39
39
|
-t TEMPLATES --templates TEMPLATES Directory containing templates and defaults folder with functionality templates and default facts
|
40
40
|
-f FACTS_DEST --facts_dest_dir FACTS_DEST Destination directory to store result facts
|
41
|
+
-x CUSTOM_FACTS_DIR --custom_facts_dir CUSTOM_FACTS_DIR Directory containing yaml files with custom facts that will be merged with ones from <hostname>_facts.yaml, custom facts can overwrite them
|
42
|
+
-m MODULE_PATH --module_path MODULE_PATH Path to find puppet modules, can be colon (:) delimited
|
41
43
|
-p PUPPET_APPLY --puppet_apply PUPPET_APPLY Custom puppet apply command to run
|
42
44
|
-r PUPPETFILE_CONFIG --puppetfile_config puppetfile_config Puppetfile composition config file
|
43
45
|
-o PUPPETFILE_OUTPUT_PATH --puppetfile_output_path PUPPETFILE_OUTPUT_PATH Result Puppetfile path
|
44
46
|
-e EYAML_KEY_PATH --eyaml_key_path EYAML_KEY_PATH Path to eyaml encryption key pair
|
45
47
|
-k --keep-facts Flag to keep the encrypted facts file in /tmp for analysis
|
48
|
+
-n --dry-run Flag to indicate puppet should run in dry run mode (--noop), this also sets the verbose flag to true
|
49
|
+
-v --verbose Flag to indicate that all output from puppet apply should be displayed instead of just stdout
|
46
50
|
Commands:
|
47
51
|
all Runs the following commands prepare, start
|
48
52
|
start Runs puppet apply
|
@@ -149,6 +153,7 @@ if options['all'] || options['prepare']
|
|
149
153
|
input_dir = options["--config_dir"] || options["-c"]
|
150
154
|
dest_dir = options["--dest_dir"] || options["-d"]
|
151
155
|
facts_dest_dir = options["--facts_dest_dir"] || options["-f"]
|
156
|
+
custom_facts_dir = options["--custom_facts_dir"] || options["-x"] || nil
|
152
157
|
templates = options["--templates"] || options["-t"]
|
153
158
|
puppetfile_config_path = options["--puppetfile_config"] || options["-r"]
|
154
159
|
puppetfile_output_path = options["--puppetfile_output_path"] || options["-o"]
|
@@ -156,6 +161,7 @@ if options['all'] || options['prepare']
|
|
156
161
|
hostname = options["--servername"] || options["-s"] || Facter.value("hostname")
|
157
162
|
puts "Hostname #{hostname}"
|
158
163
|
keep_facts = true if options["-k"] or options["--keep-facts"]
|
164
|
+
|
159
165
|
|
160
166
|
config_file_path = path_join_glob(input_dir, hostname+".yaml")
|
161
167
|
templates_dir = path_join_glob(templates, "templates")
|
@@ -349,8 +355,19 @@ if options['all'] || options['prepare']
|
|
349
355
|
end
|
350
356
|
end
|
351
357
|
|
358
|
+
# merge custom facts if parameter provided
|
359
|
+
custom_facts_all = {}
|
360
|
+
if (custom_facts_dir)
|
361
|
+
Dir.glob("#{custom_facts_dir}/*.yaml").sort.each do |custom_facts_file|
|
362
|
+
custom_facts_from_file = YAML.load_file(custom_facts_file) || {}
|
363
|
+
custom_facts_all.merge!(custom_facts_from_file)
|
364
|
+
end
|
365
|
+
end
|
366
|
+
# merge, prefer custom facts
|
367
|
+
merged_all_facts = YAML.load(output_result_default_facts).merge!(custom_facts_all)
|
368
|
+
|
352
369
|
# write the temp encrypted facts file
|
353
|
-
output_file.write(
|
370
|
+
output_file.write(merged_all_facts.to_yaml)
|
354
371
|
|
355
372
|
# now that the merged final facts are present look for any global transformations to apply
|
356
373
|
# global transformations are currently either booleans that need to be expressed directly in
|
@@ -437,7 +454,6 @@ if options['all'] || options['prepare']
|
|
437
454
|
end
|
438
455
|
}
|
439
456
|
end
|
440
|
-
|
441
457
|
output_file.write(decrypted.join)
|
442
458
|
end
|
443
459
|
|
@@ -492,10 +508,33 @@ end
|
|
492
508
|
# start puppet
|
493
509
|
if (options['start'] || options['all']) && !stop_apply
|
494
510
|
require 'puppet'
|
495
|
-
|
496
|
-
|
511
|
+
|
512
|
+
# set dry run option if the flag has been set
|
513
|
+
if options["-n"] or options["--dry-run"]
|
514
|
+
dry_run = '--noop'
|
515
|
+
verbose_output = true
|
516
|
+
else
|
517
|
+
dry_run = ''
|
518
|
+
end
|
519
|
+
|
520
|
+
# if the user has specified a module path pass it to puppet
|
521
|
+
if options["--module_path"]
|
522
|
+
modulefile_definition = "--modulepath #{options['--module_path']}"
|
523
|
+
elsif options["-m"]
|
524
|
+
modulefile_definition = "--modulepath #{options['-m']}"
|
525
|
+
# if no modulepath has been set default to /etc/puppet/modules for puppet 4 and above and blank for older versions
|
526
|
+
else
|
527
|
+
modulefile_definition = Gem::Version.new(Puppet.version) > Gem::Version.new('4.0.0') ? '--modulepath /etc/puppet/modules' : ''
|
528
|
+
end
|
529
|
+
|
530
|
+
# construct defaut puppet apply command
|
531
|
+
puppet_command = "sudo su -c 'source /usr/local/rvm/scripts/rvm; puppet apply #{dry_run} /etc/puppet/manifests/site.pp --confdir=/etc/puppet --verbose --detailed-exitcodes #{modulefile_definition}'"
|
532
|
+
|
533
|
+
# if a custom puppet apply command has been set use if, otherwise use the default generated above
|
497
534
|
to_execute = options["--puppet_apply"] || options["-p"] || puppet_command
|
498
535
|
debug "Running #{to_execute}"
|
536
|
+
|
537
|
+
# execute puppet apply and capture return code
|
499
538
|
`#{to_execute}`
|
500
539
|
exit_code = $?.exitstatus
|
501
540
|
|
@@ -514,7 +553,11 @@ if (options['start'] || options['all']) && !stop_apply
|
|
514
553
|
warning "Unable to locate Facts file, please urgently locate and remove this as it holds unencrypted values"
|
515
554
|
end
|
516
555
|
|
517
|
-
if
|
556
|
+
# if we see a bad exit code report it, for refrerence good codes are:
|
557
|
+
# 0: The run succeeded with no changes or failures; the system was already in the desired state.
|
558
|
+
# 2: The run succeeded, and some resources were changed.
|
559
|
+
if exit_code != 2 and exit_code != 0
|
518
560
|
raise "execute_puppet exit status: #{exit_code}"
|
519
561
|
end
|
520
562
|
end
|
563
|
+
|
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.25"
|
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.25
|
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-09-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
175
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.7.
|
176
|
+
rubygems_version: 2.7.7
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Preprocessor for hiera config
|