Module: RSpecSystemPuppet::Helpers

Includes:
RSpecSystem::Helpers
Defined in:
lib/rspec-system-puppet/helpers.rb

Overview

This module contains the methods provide by rspec-system-puppet

Instance Method Summary collapse

Instance Method Details

#facter(opts = {}) {|result| ... } ⇒ RSpecSystemPuppet::Helpers::Facter

Run facter on a remote machine

Parameters:

  • opts (Hash) (defaults to: {})

    a hash of opts

Options Hash (opts):

  • :puppet (Boolean)

    true to load Puppet custom facts

  • :node (RSpecSystem::Node)

    node to execute DSL on

Yields:

  • (result)

    yields result when called as a block

Yield Parameters:

  • result (RSpecSystemPuppet::Helpers::Facter)

    helper object

Returns:

  • (RSpecSystemPuppet::Helpers::Facter)

    helper object



119
120
121
# File 'lib/rspec-system-puppet/helpers.rb', line 119

def facter(opts = {}, &block)
  RSpecSystemPuppet::Helpers::Facter.new(opts, self, &block)
end

#puppet_agent(opts = {}) {|result| ... } ⇒ RSpecSystem::Helpers::PuppetAgent

Run puppet agent

Examples:

puppet_agent.do |r|
  r.exit_code.should == 0
end

with debugging enabled

puppet_agent(:debug => true).do |r|
  r.exit_code.should == 0
end

Parameters:

  • opts (Hash) (defaults to: {})

    a hash of opts

Options Hash (opts):

  • :node (RSpecSystem::Node)

    node to execute DSL on

  • :debug (Boolean)

    true if debugging required

  • :trace (Boolean)

    true if trace required

Yields:

  • (result)

    yields result when called as a block

Yield Parameters:

Returns:



53
54
55
# File 'lib/rspec-system-puppet/helpers.rb', line 53

def puppet_agent(opts = {}, &block)
  RSpecSystemPuppet::Helpers::PuppetAgent.new(opts, self, &block)
end

#puppet_apply(opts) {|result| ... } ⇒ RSpecSystem::Helpers::PuppetApply

Run puppet DSL code directly with ‘puppet apply`.

This takes a string of PuppetDSL code, uploads it to the test server and executes it directly with ‘puppet apply`.

Parameters:

  • opts (Hash, String)

    a hash of opts, or a string containing the code to execute with option defaults

Options Hash (opts):

  • :code (String)

    the Puppet DSL code to execute

  • :node (RSpecSystem::Node)

    node to execute DSL on

  • :debug (Boolean)

    true if debugging required

  • :trace (Boolean)

    true if trace required

  • :module_path (String)

    puppet modulepath to use

Yields:

  • (result)

    yields result when called as a block

Yield Parameters:

  • result (RSpecSystemPuppet::Helpers::PuppetApply)

    helper object it “run notice” do

    puppet_apply("notice('foo')") do |r|
      r.stdout.should =~ /foo/
    end
    

    end

Returns:



103
104
105
106
107
108
109
# File 'lib/rspec-system-puppet/helpers.rb', line 103

def puppet_apply(opts, &block)
  if opts.is_a?(String)
    opts = {:code => opts}
  end

  RSpecSystemPuppet::Helpers::PuppetApply.new(opts, self, &block)
end

#puppet_install(opts = {}) {|result| ... } ⇒ RspecSystemPuppet::Helpers::PuppetInstall

Basic helper to install puppet

Parameters:

  • opts (Hash) (defaults to: {})

    a hash of opts

Options Hash (opts):

  • :node (RSpecSystem::Node)

    node to execute DSL on

Yields:

  • (result)

    yields result when called as a block

Yield Parameters:

Returns:

  • (RspecSystemPuppet::Helpers::PuppetInstall)

    results



21
22
23
# File 'lib/rspec-system-puppet/helpers.rb', line 21

def puppet_install(opts = {}, &block)
  RSpecSystemPuppet::Helpers::PuppetInstall.new(opts, self, &block)
end

#puppet_master_install(opts = {}) {|result| ... } ⇒ RspecSystemPuppet::Helpers::PuppetMasterInstall

Basic helper to install a puppet master

Parameters:

  • opts (Hash) (defaults to: {})

    a hash of opts

Options Hash (opts):

  • :node (RSpecSystem::Node)

    node to execute DSL on

Yields:

  • (result)

    yields result when called as a block

Yield Parameters:

Returns:

  • (RspecSystemPuppet::Helpers::PuppetMasterInstall)

    results



32
33
34
# File 'lib/rspec-system-puppet/helpers.rb', line 32

def puppet_master_install(opts = {}, &block)
  RSpecSystemPuppet::Helpers::PuppetMasterInstall.new(opts, self, &block)
end

#puppet_module_install(opts) {|result| ... } ⇒ RSpecSystem::Helpers::PuppetModuleInstall

Helper to copy a module onto a node from source

Parameters:

  • opts (Hash)

    a hash of opts

Options Hash (opts):

  • :node (RSpecSystem::Node)

    node to execute DSL on

Yields:

  • (result)

    yields result when called as a block

Yield Parameters:

Returns:



64
65
66
# File 'lib/rspec-system-puppet/helpers.rb', line 64

def puppet_module_install(opts, &block)
  RSpecSystemPuppet::Helpers::PuppetModuleInstall.new(opts, self, &block)
end

#puppet_resource(opts) {|result| ... } ⇒ RSpecSystem::Helpers::PuppetResource

Runs puppet resource commands

Parameters:

  • opts (Hash)

    a hash of opts

Options Hash (opts):

  • :node (RSpecSystem::Node)

    node to execute DSL on

Yields:

  • (result)

    yields result when called as a block

Yield Parameters:

Returns:



75
76
77
78
79
80
81
# File 'lib/rspec-system-puppet/helpers.rb', line 75

def puppet_resource(opts, &block)
  if opts.is_a?(String)
    opts = {:resource => opts}
  end

  RSpecSystemPuppet::Helpers::PuppetResource.new(opts, self, &block)
end