Class: Beaker::TestmodeSwitcher::BeakerAgentRunner

Inherits:
BeakerRunnerBase show all
Includes:
MasterManipulator::Site
Defined in:
lib/beaker/testmode_switcher/beaker_runners.rb

Overview

All functionality specific to running in ‘agent’ mode

Instance Attribute Summary

Attributes inherited from BeakerRunnerBase

#hosts, #logger

Instance Method Summary collapse

Methods inherited from BeakerRunnerBase

#create_remote_file_ex, #initialize, #resource, #scp_to_ex, #shell_ex

Methods inherited from RunnerBase

#get_acceptable_puppet_run_exit_codes, #handle_puppet_run_returned_exit_code

Constructor Details

This class inherits a constructor from Beaker::TestmodeSwitcher::BeakerRunnerBase

Instance Method Details

#execute_manifest(manifest, opts = {}) ⇒ Object

upload the manifest to the master and inject it into the site.pp then run a puppet agent on the default host



73
74
75
# File 'lib/beaker/testmode_switcher/beaker_runners.rb', line 73

def execute_manifest(manifest, opts = {})
  execute_manifest_on(default, manifest, opts)
end

#execute_manifest_on(hosts, manifest, opts = {}) ⇒ Object

upload the manifest to the master and inject it into the site.pp then run a puppet agent on all hosts



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/beaker/testmode_switcher/beaker_runners.rb', line 79

def execute_manifest_on(hosts, manifest, opts = {})
  environment_base_path = on(master, puppet('config', 'print', 'environmentpath')).stdout.rstrip
  prod_env_site_pp_path = File.join(environment_base_path, 'production', 'manifests', 'site.pp')
  site_pp = create_site_pp(master, manifest: manifest)
  inject_site_pp(master, prod_env_site_pp_path, site_pp)

  cmd = ['agent', '--test', '--environment production', '--detailed-exitcodes']
  cmd << "--debug" if opts[:debug]
  cmd << "--noop" if opts[:noop]
  cmd << "--trace" if opts[:trace]

  # acceptable_exit_codes are passed because we want detailed-exit-codes but want to
  # make our own assertions about the responses
  res = on(hosts,
           puppet(*cmd),
           dry_run: opts[:dry_run],
           environment: opts[:environment] || {},
           acceptable_exit_codes: (0...256))

  handle_puppet_run_returned_exit_code(get_acceptable_puppet_run_exit_codes(opts), res.exit_code)
  res
end