Class: CucumberPuppet

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber-puppet.rb,
lib/cucumber-puppet/puppet.rb

Constant Summary collapse

VERSION =
[version[:major], version[:minor], version[:patch], version[:build]].compact.join('.')

Instance Method Summary collapse

Constructor Details

#initializeCucumberPuppet

Returns a new instance of CucumberPuppet.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/cucumber-puppet/puppet.rb', line 5

def initialize
  @confdir = "/etc/puppet"
  @manifest = @confdir + "/manifest/site.pp"

  # default facts
  @facts = {
    'architecture' => "",
    'domain' => "no.domain",
    'environment' => "production",
    'hostname' => "testnode",
    'lsbdistcodename' => "",
    'network_eth0' => "127.0.0.0",
    'operatingsystem' => "",
  }

  Puppet::Util::Log.newdestination(:console)
  Puppet::Util::Log.level = :notice
end

Instance Method Details

#compile_catalogObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cucumber-puppet/puppet.rb', line 32

def compile_catalog
  Puppet[:confdir] = @confdir
  Puppet[:manifest] = @manifest
  Puppet.parse_config

  node = Puppet::Node.new(@facts['hostname'], :classes => @klass)
  node.merge(@facts)

  begin
    # Compile our catalog
    @catalog = Puppet::Node::Catalog.find(node.name, :use_node => node)
  rescue => detail
    if Puppet[:trace]
      puts detail.backtrace
    end
    if detail.is_a?(XMLRPC::FaultException)
      $stderr.puts detail.message
    else
      $stderr.puts detail
    end
    exit 1
  end
end

#debugObject



24
25
26
# File 'lib/cucumber-puppet/puppet.rb', line 24

def debug
  Puppet::Util::Log.level = :debug
end

#klass=(klass) ⇒ Object



28
29
30
# File 'lib/cucumber-puppet/puppet.rb', line 28

def klass=(klass)
  @klass = klass.to_a
end

#resource(title) ⇒ Object



56
57
58
59
# File 'lib/cucumber-puppet/puppet.rb', line 56

def resource(title)
  resource = @catalog.resource(title)
  return resource
end