Class: RSpecSystem::Helpers::PuppetResource

Inherits:
RSpecSystem::Helper
  • Object
show all
Defined in:
lib/rspec-system-puppet/helpers/puppet_resource.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts, clr, &block) ⇒ PuppetResource

Returns a new instance of PuppetResource.


8
9
10
11
# File 'lib/rspec-system-puppet/helpers/puppet_resource.rb', line 8

def initialize(opts, clr, &block)
  raise "Must provide resource" unless opts[:resource]
  super(opts, clr, &block)
end

Instance Method Details

#executeHash

Run puppet resource in a shell and return results

Returns:

  • (Hash)

    results


16
17
18
19
20
21
22
23
# File 'lib/rspec-system-puppet/helpers/puppet_resource.rb', line 16

def execute
  resource = opts[:resource]
  node = opts[:node]

  log.info("Now running puppet resource")
  result = shell :c => "puppet resource #{resource}", :n => node
  result.to_hash
end