puppet_litmus 0.11.2 → 0.12.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 +4 -4
- data/lib/puppet_litmus/inventory_manipulation.rb +1 -0
- data/lib/puppet_litmus/puppet_helpers.rb +17 -6
- data/lib/puppet_litmus/rake_tasks.rb +6 -0
- data/lib/puppet_litmus/version.rb +1 -1
- data/spec/data/jim.yaml +16 -0
- data/spec/lib/puppet_litmus/puppet_helpers_spec.rb +9 -0
- metadata +10 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 41776234e4a62f7965314cc8c40d33a91ae86c5718a3af4dc3041713c53b86f0
|
|
4
|
+
data.tar.gz: a7060ae471bc8f197fc33af71a65bb5dd11cae2d54d139fb607c4e632c6c9590
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ff8a621cb6df184f8b30af5083fd1eefc945986ae2620df2cc62a8168bf2bee601ce093bbe41baa2ae922bd7796588a3be33413093ba003e1f8b39f72fee1ac0
|
|
7
|
+
data.tar.gz: 4533bda3c00d1e45463ed4c4f52d90e719610f7895ace22d7b8f2d5d24f4c0407a0280d874dbb554d769e97d06f32e506d1a8a9b1faddde6bb85269417a114e9
|
|
@@ -24,10 +24,10 @@ module PuppetLitmus::PuppetHelpers
|
|
|
24
24
|
#
|
|
25
25
|
# @param manifest [String] puppet manifest code to be applied.
|
|
26
26
|
# @param opts [Hash] Alters the behaviour of the command. Valid options are:
|
|
27
|
-
# :catch_changes [Boolean] (false) We're after idempotency so allow exit code 0 only.
|
|
28
|
-
# :expect_changes [Boolean] (false) We're after changes specifically so allow exit code 2 only.
|
|
29
|
-
# :catch_failures [Boolean] (false) We're after only complete success so allow exit codes 0 and 2 only.
|
|
30
|
-
# :expect_failures [Boolean] (false) We're after failures specifically so allow exit codes 1, 4, and 6 only.
|
|
27
|
+
# :catch_changes [Boolean] (false) We're after idempotency so allow exit code 0 only.
|
|
28
|
+
# :expect_changes [Boolean] (false) We're after changes specifically so allow exit code 2 only.
|
|
29
|
+
# :catch_failures [Boolean] (false) We're after only complete success so allow exit codes 0 and 2 only.
|
|
30
|
+
# :expect_failures [Boolean] (false) We're after failures specifically so allow exit codes 1, 4, and 6 only.
|
|
31
31
|
# :manifest_file_location [Path] The place on the target system.
|
|
32
32
|
# :hiera_config [Path] The path to the hiera.yaml configuration on the runner.
|
|
33
33
|
# :prefix_command [String] prefixes the puppet apply command; eg "export LANGUAGE='ja'".
|
|
@@ -171,16 +171,27 @@ module PuppetLitmus::PuppetHelpers
|
|
|
171
171
|
result
|
|
172
172
|
end
|
|
173
173
|
|
|
174
|
+
# rubocop:disable Layout/TrailingWhitespace
|
|
175
|
+
|
|
174
176
|
# Runs a task against the target system.
|
|
175
177
|
#
|
|
176
178
|
# @param task_name [String] The name of the task to run.
|
|
177
179
|
# @param params [Hash] key : value pairs to be passed to the task.
|
|
178
|
-
# @param opts [Hash] Alters the behaviour of the command. Valid options are
|
|
180
|
+
# @param opts [Hash] Alters the behaviour of the command. Valid options are
|
|
181
|
+
# :expect_failures [Boolean] doesnt return an exit code of non-zero if the command failed.
|
|
182
|
+
# :inventory_file [String] path to the inventory file to use with the task.
|
|
179
183
|
# @return [Object] A result object from the task.The values available are stdout, stderr and result.
|
|
184
|
+
# rubocop:enable Layout/TrailingWhitespace
|
|
180
185
|
def run_bolt_task(task_name, params = {}, opts = {})
|
|
181
186
|
config_data = { 'modulepath' => File.join(Dir.pwd, 'spec', 'fixtures', 'modules') }
|
|
182
187
|
target_node_name = targeting_localhost? ? 'litmus_localhost' : ENV['TARGET_HOST']
|
|
183
|
-
inventory_hash = File.exist?(
|
|
188
|
+
inventory_hash = if !opts[:inventory_file].nil? && File.exist?(opts[:inventory_file])
|
|
189
|
+
inventory_hash_from_inventory_file(opts[:inventory_file])
|
|
190
|
+
elsif File.exist?('inventory.yaml')
|
|
191
|
+
inventory_hash_from_inventory_file('inventory.yaml')
|
|
192
|
+
else
|
|
193
|
+
localhost_inventory_hash
|
|
194
|
+
end
|
|
184
195
|
raise "Target '#{target_node_name}' not found in inventory.yaml" unless target_in_inventory?(inventory_hash, target_node_name)
|
|
185
196
|
|
|
186
197
|
result = run_task(task_name, target_node_name, params, config: config_data, inventory: inventory_hash)
|
|
@@ -208,14 +208,20 @@ namespace :litmus do
|
|
|
208
208
|
if result['status'] != 'success'
|
|
209
209
|
command_to_run = "bolt task run puppet_agent::install --targets #{result['node']} --inventoryfile inventory.yaml --modulepath #{config_data['modulepath']}"
|
|
210
210
|
raise "Failed on #{result['node']}\n#{result}\ntry running '#{command_to_run}'"
|
|
211
|
+
else
|
|
212
|
+
# add puppet-agent feature to successful nodes
|
|
213
|
+
inventory_hash = add_feature_to_node(inventory_hash, 'puppet-agent', result['node'])
|
|
211
214
|
end
|
|
212
215
|
end
|
|
216
|
+
# update the inventory with the puppet-agent feature set per node
|
|
217
|
+
write_to_inventory_file(inventory_hash, 'inventory.yaml')
|
|
213
218
|
|
|
214
219
|
# fix the path on ssh_nodes
|
|
215
220
|
unless inventory_hash['groups'].select { |group| group['name'] == 'ssh_nodes' }.size.zero?
|
|
216
221
|
results = run_command('echo PATH="$PATH:/opt/puppetlabs/puppet/bin" > /etc/environment',
|
|
217
222
|
'ssh_nodes', config: nil, inventory: inventory_hash)
|
|
218
223
|
end
|
|
224
|
+
|
|
219
225
|
results.each do |result|
|
|
220
226
|
if result['status'] != 'success'
|
|
221
227
|
puts "Failed on #{result['node']}\n#{result}"
|
data/spec/data/jim.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
groups:
|
|
3
|
+
- name: ssh_nodes
|
|
4
|
+
nodes:
|
|
5
|
+
- name: test.delivery.puppetlabs.net
|
|
6
|
+
config:
|
|
7
|
+
transport: ssh
|
|
8
|
+
ssh:
|
|
9
|
+
user: root
|
|
10
|
+
password: Qu@lity!
|
|
11
|
+
host-key-check: false
|
|
12
|
+
facts:
|
|
13
|
+
provisioner: vmpooler
|
|
14
|
+
platform: centos-5-x86_64
|
|
15
|
+
- name: winrm_nodes
|
|
16
|
+
nodes: []
|
|
@@ -249,6 +249,15 @@ RSpec.describe PuppetLitmus::PuppetHelpers do
|
|
|
249
249
|
expect { described_class.run_bolt_task(task_name, params, opts: {}) }.not_to raise_error
|
|
250
250
|
end
|
|
251
251
|
|
|
252
|
+
it 'does bolt_task_run gives no runtime error for success, for a named inventory file' do
|
|
253
|
+
stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
|
|
254
|
+
expect(File).to receive(:exist?).with('jim.yaml').and_return(true)
|
|
255
|
+
expect(described_class).to receive(:inventory_hash_from_inventory_file).and_return(inventory_hash)
|
|
256
|
+
expect(described_class).to receive(:target_in_inventory?).and_return(true)
|
|
257
|
+
expect(described_class).to receive(:run_task).with(task_name, 'some.host', params, config: config_data, inventory: inventory_hash).and_return(result_unstructured_task_success)
|
|
258
|
+
expect { described_class.run_bolt_task(task_name, params, inventory_file: 'jim.yaml') }.not_to raise_error
|
|
259
|
+
end
|
|
260
|
+
|
|
252
261
|
it 'returns stdout for unstructured-data tasks' do
|
|
253
262
|
stub_const('ENV', ENV.to_hash.merge('TARGET_HOST' => 'some.host'))
|
|
254
263
|
expect(File).to receive(:exist?).with('inventory.yaml').and_return(true)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: puppet_litmus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Puppet, Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-10-
|
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bolt
|
|
@@ -107,6 +107,7 @@ files:
|
|
|
107
107
|
- lib/puppet_litmus/version.rb
|
|
108
108
|
- spec/data/doot.tar.gz
|
|
109
109
|
- spec/data/inventory.yaml
|
|
110
|
+
- spec/data/jim.yaml
|
|
110
111
|
- spec/lib/puppet_litmus/inventory_manipulation_spec.rb
|
|
111
112
|
- spec/lib/puppet_litmus/puppet_helpers_spec.rb
|
|
112
113
|
- spec/lib/puppet_litmus/rake_tasks_spec.rb
|
|
@@ -131,17 +132,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
131
132
|
- !ruby/object:Gem::Version
|
|
132
133
|
version: '0'
|
|
133
134
|
requirements: []
|
|
134
|
-
|
|
135
|
-
rubygems_version: 2.7.8
|
|
135
|
+
rubygems_version: 3.0.4
|
|
136
136
|
signing_key:
|
|
137
137
|
specification_version: 4
|
|
138
138
|
summary: Providing a simple command line tool for puppet content creators, to enable
|
|
139
139
|
simple and complex test deployments.
|
|
140
140
|
test_files:
|
|
141
|
-
- spec/spec_helper.rb
|
|
142
|
-
- spec/lib/puppet_litmus/rake_tasks_spec.rb
|
|
143
|
-
- spec/lib/puppet_litmus/version_spec.rb
|
|
144
|
-
- spec/lib/puppet_litmus/inventory_manipulation_spec.rb
|
|
145
|
-
- spec/lib/puppet_litmus/puppet_helpers_spec.rb
|
|
146
141
|
- spec/data/doot.tar.gz
|
|
147
142
|
- spec/data/inventory.yaml
|
|
143
|
+
- spec/data/jim.yaml
|
|
144
|
+
- spec/lib/puppet_litmus/inventory_manipulation_spec.rb
|
|
145
|
+
- spec/lib/puppet_litmus/puppet_helpers_spec.rb
|
|
146
|
+
- spec/lib/puppet_litmus/rake_tasks_spec.rb
|
|
147
|
+
- spec/lib/puppet_litmus/version_spec.rb
|
|
148
|
+
- spec/spec_helper.rb
|