Class: RSpecSystem::Helpers::PuppetApply
- Inherits:
-
RSpecSystem::Helper
- Object
- RSpecSystem::Helper
- RSpecSystem::Helpers::PuppetApply
- Defined in:
- lib/rspec-system-puppet/helpers/puppet_apply.rb
Overview
puppet_apply helper
Instance Method Summary collapse
-
#execute ⇒ Hash
Run puppet apply in a shell and return results.
-
#initialize(opts, clr, &block) ⇒ PuppetApply
constructor
A new instance of PuppetApply.
Constructor Details
#initialize(opts, clr, &block) ⇒ PuppetApply
Returns a new instance of PuppetApply.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rspec-system-puppet/helpers/puppet_apply.rb', line 9 def initialize(opts, clr, &block) # Defaults opts = { :debug => false, :trace => true, }.merge(opts) raise 'Must provide code' unless opts[:code] super(opts, clr, &block) end |
Instance Method Details
#execute ⇒ Hash
Run puppet apply in a shell and return results
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rspec-system-puppet/helpers/puppet_apply.rb', line 24 def execute code = opts[:code] node = opts[:node] log.info("Copying DSL to remote host") file = Tempfile.new('rcp_puppet_apply') file.write(code) file.close remote_path = '/tmp/puppetapply.' + rand(1000000000).to_s r = rcp(:sp => file.path, :dp => remote_path, :d => node) file.unlink log.info("Cat file to see contents") shell :c => "cat #{remote_path}", :n => node log.info("Now running puppet apply") cmd = "puppet apply --detailed-exitcodes" cmd += " --debug" if opts[:debug] cmd += " --trace" if opts[:trace] cmd += " --modulepath #{opts[:module_path]}" if opts[:module_path] cmd += " #{remote_path}" shell(:c => cmd, :n => node).to_hash end |