puppet_litmus 0.18.0 → 0.19.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.
@@ -17,15 +17,15 @@ namespace :litmus do
17
17
  end
18
18
 
19
19
  # Provisions a list of OSes from provision.yaml file e.g. 'bundle exec rake litmus:provision_list[default]'.
20
- # @See https://github.com/puppetlabs/puppet_litmus/wiki/Overview-of-Litmus#provisioning-via-yaml
20
+ # @See https://puppetlabs.github.io/litmus/Litmus-core-commands.html#provisioning-via-yaml
21
21
  #
22
22
  # @param :key [String] key that maps to a value for a provisioner and an image to be used for each OS provisioned.
23
- desc "provision list of machines from provision.yaml file. 'bundle exec rake 'litmus:provision_list[default]'"
23
+ desc 'provision list of machines from provision.yaml file'
24
24
  task :provision_list, [:key] do |_task, args|
25
25
  raise 'Cannot find provision.yaml file' unless File.file?('./provision.yaml')
26
26
 
27
27
  provision_hash = YAML.load_file('./provision.yaml')
28
- raise "No key #{args[:key]} in ./provision.yaml, see https://github.com/puppetlabs/puppet_litmus/wiki/Overview-of-Litmus#provisioning-via-yaml for examples" if provision_hash[args[:key]].nil?
28
+ raise "No key #{args[:key]} in ./provision.yaml, see https://puppetlabs.github.io/litmus/Litmus-core-commands.html#provisioning-via-yaml for examples" if provision_hash[args[:key]].nil?
29
29
 
30
30
  Rake::Task['spec_prep'].invoke
31
31
 
@@ -59,7 +59,7 @@ namespace :litmus do
59
59
  if result.first['status'] != 'success'
60
60
  failed_image_message += "=====\n#{result.first['target']}\n#{result.first['value']['_output']}\n#{result.inspect}"
61
61
  else
62
- STDOUT.puts "#{result.first['value']['node_name']}, #{image}"
62
+ $stdout.puts "#{result.first['value']['node_name']}, #{image}"
63
63
  end
64
64
  results << result
65
65
  end
@@ -71,7 +71,7 @@ namespace :litmus do
71
71
  #
72
72
  # @param :provisioner [String] provisioner to use in provisioning given platform.
73
73
  # @param :platform [String] OS platform for container or VM to use.
74
- desc "provision container/VM - abs/docker/vagrant/vmpooler eg 'bundle exec rake 'litmus:provision[vmpooler, ubuntu-1604-x86_64]'"
74
+ desc 'provision a test system using the given provisioner and platform name. See the puppetlabs-provision module tasks for more documentation'
75
75
  task :provision, [:provisioner, :platform, :inventory_vars] do |_task, args|
76
76
  Rake::Task['spec_prep'].invoke
77
77
  if (ENV['CI'] == 'true') || !ENV['DISTELLI_BUILDNUM'].nil?
@@ -103,7 +103,7 @@ namespace :litmus do
103
103
  #
104
104
  # @param :collection [String] parameters to pass to the puppet agent install command.
105
105
  # @param :target_node_name [Array] nodes on which to install puppet agent.
106
- desc 'install puppet agent, [:collection, :target_node_name]'
106
+ desc 'install a puppet agent to all or a specified set of targets'
107
107
  task :install_agent, [:collection, :target_node_name] do |_task, args|
108
108
  inventory_hash = inventory_hash_from_inventory_file
109
109
  targets = find_targets(inventory_hash, args[:target_node_name])
@@ -122,28 +122,41 @@ namespace :litmus do
122
122
  command_to_run = "bolt task run puppet_agent::install --targets #{result['target']} --inventoryfile inventory.yaml --modulepath #{DEFAULT_CONFIG_DATA['modulepath']}"
123
123
  raise "Failed on #{result['target']}\n#{result}\ntry running '#{command_to_run}'"
124
124
  else
125
+ # validate successful install
126
+ puts "Successfull install result: #{result.inspect}" if ENV['DEBUG'] == true
127
+ retries = 0
128
+ begin
129
+ responses = run_command('puppet --version', targets, options: {}, config: DEFAULT_CONFIG_DATA, inventory: inventory_hash.clone)
130
+ responses.each do |response|
131
+ raise "Error checking puppet version on #{response.to_json}" if response['status'] != 'success'
132
+ end
133
+ rescue StandardError => e
134
+ puts "ERROR:#{e}"
135
+ # fix the path
136
+ path_changes = configure_path(inventory_hash)
137
+ path_changes.each do |change|
138
+ puts "Configuring puppet path result: #{change.inspect}"
139
+ end
140
+
141
+ retries += 1
142
+ sleep 3
143
+ retry if retries <= 300
144
+ raise 'Failed to detect installed puppet version after 5 minutes'
145
+ end
146
+
125
147
  # add puppet-agent feature to successful nodes
126
148
  inventory_hash = add_feature_to_node(inventory_hash, 'puppet-agent', result['target'])
127
149
  end
128
150
  end
129
151
  # update the inventory with the puppet-agent feature set per node
130
152
  write_to_inventory_file(inventory_hash, 'inventory.yaml')
131
-
132
- # fix the path on ssh_nodes
133
- results = configure_path(inventory_hash)
134
-
135
- results.each do |result|
136
- if result['status'] != 'success'
137
- puts "Failed on #{result['target']}\n#{result}"
138
- end
139
- end
140
153
  end
141
154
 
142
155
  # Add a given feature to a selection of nodes
143
156
  #
144
157
  # @param :target_node_name [Array] nodes on which to add the feature.
145
158
  # @param :added_feature [String] the feature which you wish to add.
146
- desc 'add_feature, [:added_feature, :target_node_name]'
159
+ desc 'add a feature tag to a node'
147
160
  task :add_feature, [:added_feature, :target_node_name] do |_task, args|
148
161
  inventory_hash = inventory_hash_from_inventory_file
149
162
  targets = find_targets(inventory_hash, args[:target_node_name])
@@ -166,83 +179,118 @@ namespace :litmus do
166
179
  puts 'Feature added'
167
180
  end
168
181
 
182
+ # Install the puppet module under test on a collection of nodes
183
+ #
184
+ # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
185
+ desc 'build the module under test and install it onto targets'
186
+ task :install_module, [:target_node_name, :module_repository] do |_task, args|
187
+ args.with_defaults(target_node_name: nil, module_repository: nil)
188
+ inventory_hash = inventory_hash_from_inventory_file
189
+ target_nodes = find_targets(inventory_hash, args[:target_node_name])
190
+ if target_nodes.empty?
191
+ puts 'No targets found'
192
+ exit 0
193
+ end
194
+
195
+ module_tar = build_module
196
+ puts "Built '#{module_tar}'"
197
+
198
+ # module_tar = Dir.glob('pkg/*.tar.gz').max_by { |f| File.mtime(f) }
199
+ raise "Unable to find package in 'pkg/*.tar.gz'" if module_tar.nil?
200
+
201
+ install_module(inventory_hash, args[:target_node_name], module_tar, args[:module_repository])
202
+
203
+ puts "Installed '#{module_tar}' on #{args[:target_node_name]}"
204
+ end
205
+
169
206
  # Install the puppet modules from a source directory to nodes. It does not install dependencies.
170
207
  #
171
208
  # @param :source [String] source directory to look in (ignores symlinks) defaults do './spec/fixtures/modules'.
172
209
  # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
173
- desc 'install_module - build and install module'
174
- task :install_modules_from_directory, [:source, :target_node_name, :module_repository] do |_task, args|
175
- args.with_defaults(source: nil, target_node_name: nil, module_repository: 'https://forgeapi.puppetlabs.com')
210
+ desc 'build and install all modules from a directory'
211
+ task :install_modules_from_directory, [:source, :target_node_name, :module_repository, :ignore_dependencies] do |_task, args|
212
+ args.with_defaults(source: nil, target_node_name: nil, module_repository: nil, ignore_dependencies: false)
176
213
  inventory_hash = inventory_hash_from_inventory_file
177
214
  target_nodes = find_targets(inventory_hash, args[:target_node_name])
178
215
  if target_nodes.empty?
179
216
  puts 'No targets found'
180
217
  exit 0
181
218
  end
182
- source_folder = if args[:source].nil?
183
- './spec/fixtures/modules'
184
- else
185
- File.expand_path(args[:source])
186
- end
187
- raise "Source folder doesnt exist #{source_folder}" unless File.directory?(source_folder)
188
-
189
- puts 'Building'
190
- module_tars = build_modules_in_folder(source_folder)
219
+ source_dir = if args[:source].nil?
220
+ './spec/fixtures/modules'
221
+ else
222
+ File.expand_path(args[:source])
223
+ end
224
+ raise "Source directory doesn't exist #{source_dir}" unless File.directory?(source_dir)
225
+
226
+ puts "Building all modules in #{source_dir.inspect}"
227
+ module_tars = build_modules_in_dir(source_dir)
191
228
  require 'bolt_spec/run'
192
229
  include BoltSpec::Run
193
- puts "\nInstalling"
194
230
  module_tars.each do |module_tar|
231
+ puts "Installing '#{module_tar}'"
195
232
  target_nodes.each do |target_node_name|
196
- install_module(inventory_hash, target_node_name, module_tar, args[:module_repository])
233
+ install_module(inventory_hash, target_node_name, module_tar, args[:module_repository], args[:ignore_dependencies])
234
+ puts "Installed '#{module_tar}' on #{target_node_name}"
197
235
  end
198
236
  end
199
237
  end
200
238
 
201
- # Check that the nodes in the inventory are still contactable
239
+ # Uninstall the puppet module under test on a collection of nodes
202
240
  #
203
- # @param :target_node_name [Array] nodes on which to check connnectivity
204
- desc 'check_connectivity - build and install module'
205
- task :check_connectivity, [:target_node_name] do |_task, args|
241
+ # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
242
+ # @param :module_name [String] module name to be uninstalled
243
+ desc 'uninstall a specific module'
244
+ task :uninstall_module, [:target_node_name, :module_name] do |_task, args|
206
245
  inventory_hash = inventory_hash_from_inventory_file
207
246
  target_nodes = find_targets(inventory_hash, args[:target_node_name])
208
247
  if target_nodes.empty?
209
248
  puts 'No targets found'
210
249
  exit 0
211
250
  end
212
- check_connectivity?(inventory_hash, args[:target_node_name])
251
+
252
+ result = uninstall_module(inventory_hash, args[:target_node_name], args[:module_name])
253
+
254
+ raise "Failed trying to run 'puppet module uninstall #{module_name}' against inventory." unless result.is_a?(Array)
255
+
256
+ result.each do |node|
257
+ puts "#{node['target']} failed #{node['value']}" if node['status'] != 'success'
258
+ end
259
+
260
+ puts 'Uninstalled'
213
261
  end
214
262
 
215
- # Install the puppet module under test on a collection of nodes
263
+ # Reinstall the puppet module under test on a collection of nodes
216
264
  #
217
265
  # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
218
- desc 'install_module - build and install module'
219
- task :install_module, [:target_node_name, :module_repository] do |_task, args|
220
- args.with_defaults(target_node_name: nil, module_repository: 'https://forgeapi.puppetlabs.com')
266
+ desc 'reinstall the module under test'
267
+ task :reinstall_module, [:target_node_name, :module_repository] do |_task, args|
268
+ args.with_defaults(target_node_name: nil, module_repository: nil)
269
+ Rake::Task['litmus:uninstall_module'].invoke(args[:target_node_name])
270
+ Rake::Task['litmus:install_module'].invoke(args[:target_node_name], args[:module_repository])
271
+ end
272
+
273
+ # Check that the nodes in the inventory are still contactable
274
+ #
275
+ # @param :target_node_name [Array] nodes on which to check connnectivity
276
+ desc 'check the connectivity to all provisioned targets'
277
+ task :check_connectivity, [:target_node_name] do |_task, args|
221
278
  inventory_hash = inventory_hash_from_inventory_file
222
279
  target_nodes = find_targets(inventory_hash, args[:target_node_name])
223
280
  if target_nodes.empty?
224
281
  puts 'No targets found'
225
282
  exit 0
226
283
  end
227
-
228
- module_tar = build_module
229
- puts 'Built'
230
-
231
- # module_tar = Dir.glob('pkg/*.tar.gz').max_by { |f| File.mtime(f) }
232
- raise "Unable to find package in 'pkg/*.tar.gz'" if module_tar.nil?
233
-
234
- install_module(inventory_hash, args[:target_node_name], module_tar, args[:module_repository])
235
-
236
- puts 'Installed'
284
+ check_connectivity?(inventory_hash, args[:target_node_name])
237
285
  end
238
286
 
239
287
  # Provision a list of machines, install a puppet agent, and install the puppet module under test on a collection of nodes
240
288
  #
241
289
  # @param :key [String] key that maps to a value for a provisioner and an image to be used for each OS provisioned.
242
290
  # @param :collection [String] parameters to pass to the puppet agent install command.
243
- desc 'provision_install - provision a list of machines, install an agent, and the module.'
291
+ desc 'provision a list of machines, install an agent, and the module.'
244
292
  task :provision_install, [:key, :collection, :module_repository] do |_task, args|
245
- args.with_defaults(module_repository: 'https://forgeapi.puppetlabs.com')
293
+ args.with_defaults(module_repository: nil)
246
294
  Rake::Task['spec_prep'].invoke
247
295
  Rake::Task['litmus:provision_list'].invoke(args[:key])
248
296
  Rake::Task['litmus:install_agent'].invoke(args[:collection])
@@ -252,7 +300,7 @@ namespace :litmus do
252
300
  # Decommissions test machines.
253
301
  #
254
302
  # @param :target [Array] nodes to remove from test environemnt and decommission.
255
- desc 'tear-down - decommission machines'
303
+ desc 'destroy provisioned targets'
256
304
  task :tear_down, [:target] do |_task, args|
257
305
  inventory_hash = inventory_hash_from_inventory_file
258
306
  targets = find_targets(inventory_hash, args[:target])
@@ -278,40 +326,6 @@ namespace :litmus do
278
326
  end
279
327
  end
280
328
 
281
- # Uninstall the puppet module under test on a collection of nodes
282
- #
283
- # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
284
- # @param :module_name [String] module name to be uninstalled
285
- desc 'uninstall_module - uninstall module'
286
- task :uninstall_module, [:target_node_name, :module_name] do |_task, args|
287
- inventory_hash = inventory_hash_from_inventory_file
288
- target_nodes = find_targets(inventory_hash, args[:target_node_name])
289
- if target_nodes.empty?
290
- puts 'No targets found'
291
- exit 0
292
- end
293
-
294
- result = uninstall_module(inventory_hash, args[:target_node_name], args[:module_name])
295
-
296
- raise "Failed trying to run 'puppet module uninstall #{module_name}' against inventory." unless result.is_a?(Array)
297
-
298
- result.each do |node|
299
- puts "#{node['target']} failed #{node['value']}" if node['status'] != 'success'
300
- end
301
-
302
- puts 'Uninstalled'
303
- end
304
-
305
- # Reinstall the puppet module under test on a collection of nodes
306
- #
307
- # @param :target_node_name [Array] nodes on which to install a puppet module for testing.
308
- desc 'reinstall_module - reinstall module'
309
- task :reinstall_module, [:target_node_name, :module_repository] do |_task, args|
310
- args.with_defaults(target_node_name: nil, module_repository: 'https://forgeapi.puppetlabs.com')
311
- Rake::Task['litmus:uninstall_module'].invoke(args[:target_node_name])
312
- Rake::Task['litmus:install_module'].invoke(args[:target_node_name], args[:module_repository])
313
- end
314
-
315
329
  namespace :acceptance do
316
330
  require 'rspec/core/rake_task'
317
331
  if File.file?('inventory.yaml')
@@ -320,15 +334,21 @@ namespace :litmus do
320
334
 
321
335
  # Run acceptance tests against all machines in the inventory file in parallel.
322
336
  desc 'Run tests in parallel against all machines in the inventory file'
323
- task :parallel do
337
+ task :parallel, [:tag] do |_task, args|
338
+ args.with_defaults(tag: nil)
324
339
  if targets.empty?
325
340
  puts 'No targets found'
326
341
  exit 0
327
342
  end
343
+ tag_value = if args[:tag].nil?
344
+ nil
345
+ else
346
+ "--tag #{args[:tag]}"
347
+ end
328
348
  payloads = []
329
349
  # Generate list of targets to provision
330
350
  targets.each do |target|
331
- test = 'bundle exec rspec ./spec/acceptance --format progress --require rspec_honeycomb_formatter --format RSpecHoneycombFormatter'
351
+ test = "bundle exec rspec ./spec/acceptance #{tag_value} --format progress --require rspec_honeycomb_formatter --format RSpecHoneycombFormatter"
332
352
  title = "#{target}, #{facts_from_node(inventory_hash, target)['platform']}"
333
353
  options = {
334
354
  env: {
@@ -354,17 +374,21 @@ namespace :litmus do
354
374
 
355
375
  require 'parallel'
356
376
  results = Parallel.map(payloads) do |title, test, options|
377
+ # avoid sending the parent process' main span in the sub-processes
378
+ # https://www.ruby-forum.com/t/at-exit-inherited-across-fork/122473/2
379
+ at_exit { exit! }
380
+
357
381
  env = options[:env].nil? ? {} : options[:env]
358
- ENV['HTTP_X_HONEYCOMB_TRACE'] = Honecomb.current_span.to_trace_header unless ENV['HTTP_X_HONEYCOMB_TRACE']
382
+ env['HTTP_X_HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header
359
383
  stdout, stderr, status = Open3.capture3(env, test)
360
384
  ["\n================\n#{title}\n", stdout, stderr, status]
361
385
  end
362
386
  # because we cannot modify variables inside of Parallel
363
387
  results.each do |result|
364
388
  if result.last.to_i.zero?
365
- success_list.push(result.first.scan(%r{.*})[2])
389
+ success_list.push(result.first.scan(%r{.*})[3])
366
390
  else
367
- failure_list.push(result.first.scan(%r{.*})[2])
391
+ failure_list.push(result.first.scan(%r{.*})[3])
368
392
  end
369
393
  end
370
394
  Thread.kill(progress)
@@ -373,8 +397,8 @@ namespace :litmus do
373
397
  spinners = TTY::Spinner::Multi.new("[:spinner] Running against #{targets.size} targets.")
374
398
  payloads.each do |title, test, options|
375
399
  env = options[:env].nil? ? {} : options[:env]
400
+ env['HTTP_X_HONEYCOMB_TRACE'] = Honeycomb.current_span.to_trace_header
376
401
  spinners.register("[:spinner] #{title}") do |sp|
377
- ENV['HTTP_X_HONEYCOMB_TRACE'] = Honecomb.current_span.to_trace_header unless ENV['HTTP_X_HONEYCOMB_TRACE']
378
402
  stdout, stderr, status = Open3.capture3(env, test)
379
403
  if status.to_i.zero?
380
404
  sp.success
@@ -406,8 +430,9 @@ namespace :litmus do
406
430
  desc "Run serverspec against #{target}"
407
431
  next if target == 'litmus_localhost'
408
432
 
409
- RSpec::Core::RakeTask.new(target.to_sym) do |t|
433
+ RSpec::Core::RakeTask.new(target.to_sym, :tag) do |t, args|
410
434
  t.pattern = 'spec/acceptance/**{,/*/**}/*_spec.rb'
435
+ t.rspec_opts = "--tag #{args[:tag]}" unless args[:tag].nil?
411
436
  ENV['TARGET_HOST'] = target
412
437
  end
413
438
  end
@@ -416,8 +441,9 @@ namespace :litmus do
416
441
  # add localhost separately
417
442
  desc 'Run serverspec against localhost, USE WITH CAUTION, this action can be potentially dangerous.'
418
443
  host = 'localhost'
419
- RSpec::Core::RakeTask.new(host.to_sym) do |t|
444
+ RSpec::Core::RakeTask.new(host.to_sym, :tag) do |t, args|
420
445
  t.pattern = 'spec/acceptance/**{,/*/**}/*_spec.rb'
446
+ t.rspec_opts = "--tag #{args[:tag]}" unless args[:tag].nil?
421
447
  Rake::Task['spec_prep'].invoke
422
448
  ENV['TARGET_HOST'] = host
423
449
  end
@@ -35,6 +35,7 @@ module PuppetLitmus
35
35
  options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil?
36
36
  options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil?
37
37
  options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil?
38
+ run_as = node_config.dig('ssh', 'run-as') unless node_config.dig('ssh', 'run-as').nil?
38
39
  # Support both net-ssh 4 and 5.
39
40
  # rubocop:disable Metrics/BlockNesting
40
41
  options[:verify_host_key] = if node_config.dig('ssh', 'host-key-check').nil?
@@ -66,7 +67,9 @@ module PuppetLitmus
66
67
  end
67
68
  set :host, options[:host_name] || host
68
69
  set :ssh_options, options
69
- set :request_pty, true
70
+ set :request_pty, false
71
+ set :sudo_password, options[:password] if run_as
72
+ puts "Running tests as #{run_as}" if run_as
70
73
  elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes')
71
74
  require 'winrm'
72
75
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  # version of this gem
4
4
  module PuppetLitmus
5
- VERSION ||= '0.18.0'
5
+ VERSION ||= '0.19.0'
6
6
  end
@@ -92,70 +92,70 @@ RSpec.describe PuppetLitmus::InventoryManipulation do
92
92
  end
93
93
 
94
94
  it 'no matching node, raises' do
95
- expect { described_class.config_from_node(config_hash, 'not.here') }.to raise_error('No config was found for not.here')
95
+ expect { config_from_node(config_hash, 'not.here') }.to raise_error('No config was found for not.here')
96
96
  end
97
97
 
98
98
  it 'no config section, returns nil' do
99
- expect(described_class.config_from_node(no_config_hash, 'test.delivery.puppetlabs.net')).to eq(nil)
99
+ expect(config_from_node(no_config_hash, 'test.delivery.puppetlabs.net')).to eq(nil)
100
100
  end
101
101
 
102
102
  it 'config exists, and returns' do
103
- expect(described_class.config_from_node(config_hash, 'test.delivery.puppetlabs.net')).to eq('transport' => 'ssh', 'ssh' =>
103
+ expect(config_from_node(config_hash, 'test.delivery.puppetlabs.net')).to eq('transport' => 'ssh', 'ssh' =>
104
104
  { 'user' => 'root', 'password' => 'Qu@lity!', 'host-key-check' => false })
105
105
  end
106
106
 
107
107
  it 'facts exists, and returns' do
108
- expect(described_class.facts_from_node(config_hash, 'test.delivery.puppetlabs.net')).to eq('provisioner' => 'vmpooler', 'platform' => 'centos-5-x86_64')
108
+ expect(facts_from_node(config_hash, 'test.delivery.puppetlabs.net')).to eq('provisioner' => 'vmpooler', 'platform' => 'centos-5-x86_64')
109
109
  end
110
110
 
111
111
  it 'vars exists, and returns' do
112
- expect(described_class.vars_from_node(config_hash, 'test.delivery.puppetlabs.net')).to eq('role' => 'agent')
112
+ expect(vars_from_node(config_hash, 'test.delivery.puppetlabs.net')).to eq('role' => 'agent')
113
113
  end
114
114
 
115
115
  it 'no feature exists for the group, and returns hash with feature added' do
116
- expect(described_class.add_feature_to_group(no_feature_hash, 'puppet-agent', 'ssh_nodes')).to eq('groups' => [{ 'features' => ['puppet-agent'], 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net' }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
116
+ expect(add_feature_to_group(no_feature_hash, 'puppet-agent', 'ssh_nodes')).to eq('groups' => [{ 'features' => ['puppet-agent'], 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net' }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
117
117
  end
118
118
 
119
119
  it 'feature exists for the group, and returns hash with feature removed' do
120
- expect(described_class.remove_feature_from_group(feature_hash_group, 'puppet-agent', 'ssh_nodes')).to eq('groups' => [{ 'features' => [], 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net' }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
120
+ expect(remove_feature_from_group(feature_hash_group, 'puppet-agent', 'ssh_nodes')).to eq('groups' => [{ 'features' => [], 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net' }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
121
121
  end
122
122
 
123
123
  it 'write from inventory_hash to inventory_yaml file feature_hash_group' do
124
- expect { described_class.write_to_inventory_file(feature_hash_group, inventory_full_path) }.not_to raise_error
124
+ expect { write_to_inventory_file(feature_hash_group, inventory_full_path) }.not_to raise_error
125
125
  end
126
126
 
127
127
  it 'empty feature exists for the group, and returns hash with feature added' do
128
- expect(described_class.add_feature_to_group(empty_feature_hash_group, 'puppet-agent', 'ssh_nodes')).to eq('groups' => [{ 'features' => ['puppet-agent'], 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net' }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
128
+ expect(add_feature_to_group(empty_feature_hash_group, 'puppet-agent', 'ssh_nodes')).to eq('groups' => [{ 'features' => ['puppet-agent'], 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net' }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
129
129
  end
130
130
 
131
131
  it 'no feature exists for the node, and returns hash with feature added' do
132
- expect(described_class.add_feature_to_node(no_feature_hash, 'puppet-agent', 'test.delivery.puppetlabs.net')).to eq('groups' => [{ 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net', 'features' => ['puppet-agent'] }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
132
+ expect(add_feature_to_node(no_feature_hash, 'puppet-agent', 'test.delivery.puppetlabs.net')).to eq('groups' => [{ 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net', 'features' => ['puppet-agent'] }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
133
133
  end
134
134
 
135
135
  it 'feature exists for the node, and returns hash with feature removed' do
136
- expect(described_class.remove_feature_from_node(feature_hash_node, 'puppet-agent', 'test.delivery.puppetlabs.net')).to eq('groups' => [{ 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net', 'features' => [] }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
136
+ expect(remove_feature_from_node(feature_hash_node, 'puppet-agent', 'test.delivery.puppetlabs.net')).to eq('groups' => [{ 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net', 'features' => [] }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
137
137
  end
138
138
 
139
139
  it 'write from inventory_hash to inventory_yaml file feature_hash_node' do
140
- expect { described_class.write_to_inventory_file(feature_hash_node, inventory_full_path) }.not_to raise_error
140
+ expect { write_to_inventory_file(feature_hash_node, inventory_full_path) }.not_to raise_error
141
141
  end
142
142
 
143
143
  it 'empty feature exists for the node, and returns hash with feature added' do
144
- expect(described_class.add_feature_to_node(empty_feature_hash_node, 'puppet-agent', 'test.delivery.puppetlabs.net')).to eq('groups' => [{ 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net', 'features' => ['puppet-agent'] }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
144
+ expect(add_feature_to_node(empty_feature_hash_node, 'puppet-agent', 'test.delivery.puppetlabs.net')).to eq('groups' => [{ 'name' => 'ssh_nodes', 'targets' => [{ 'config' => { 'ssh' => { 'host-key-check' => false, 'password' => 'Qu@lity!', 'user' => 'root' }, 'transport' => 'ssh' }, 'facts' => { 'platform' => 'centos-5-x86_64', 'provisioner' => 'vmpooler' }, 'uri' => 'test.delivery.puppetlabs.net', 'features' => ['puppet-agent'] }] }, { 'name' => 'winrm_nodes', 'targets' => [] }]) # rubocop:disable Layout/LineLength: Line is too long
145
145
  end
146
146
 
147
147
  it 'write from inventory_hash to inventory_yaml file no feature_hash' do
148
148
  expect(File).to exist(inventory_full_path)
149
- expect { described_class.write_to_inventory_file(no_feature_hash, inventory_full_path) }.not_to raise_error
149
+ expect { write_to_inventory_file(no_feature_hash, inventory_full_path) }.not_to raise_error
150
150
  end
151
151
 
152
152
  it 'group does not exist in inventory, and returns hash with group added' do
153
- expect(described_class.add_node_to_group(no_docker_hash, foo_node, 'docker_nodes')).to eq('groups' =>
153
+ expect(add_node_to_group(no_docker_hash, foo_node, 'docker_nodes')).to eq('groups' =>
154
154
  [{ 'name' => 'ssh_nodes', 'targets' => [] }, { 'name' => 'winrm_nodes', 'targets' => [] }, { 'name' => 'docker_nodes', 'targets' => [foo_node] }])
155
155
  end
156
156
 
157
157
  it 'group exists in inventory, and returns hash with node added' do
158
- expect(described_class.add_node_to_group(no_docker_hash, foo_node, 'ssh_nodes')).to eq('groups' =>
158
+ expect(add_node_to_group(no_docker_hash, foo_node, 'ssh_nodes')).to eq('groups' =>
159
159
  [{ 'name' => 'ssh_nodes', 'targets' => [foo_node] }, { 'name' => 'winrm_nodes', 'targets' => [] }])
160
160
  end
161
161
  end