Class: CucumberPuppet
- Inherits:
-
Object
- Object
- CucumberPuppet
- Defined in:
- lib/cucumber-puppet/puppet.rb,
lib/cucumber-puppet.rb
Overview
A class for accessing Puppet’s internal state regarding a certain node or class.
Defined Under Namespace
Modules: Helper
Constant Summary collapse
- VERSION =
[version[:major], version[:minor], version[:patch], version[:build]].compact.join('.')
Instance Method Summary collapse
-
#compile_catalog(node = nil) ⇒ Object
Compile catalog for configured testnode.
-
#debug ⇒ Object
Set Puppet’s log level to ‘debug’.
-
#get_resource(title) ⇒ Object
Returns an Object with the given title from catalog.
-
#initialize ⇒ CucumberPuppet
constructor
Returns a new CucumberPuppet object.
-
#klass=(klass) ⇒ Object
Define Puppet classes to include in a feature’s testnode.
-
#resource(title) ⇒ Object
XXX add deprecation warning for resource().
Constructor Details
#initialize ⇒ CucumberPuppet
Returns a new CucumberPuppet object.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cucumber-puppet/puppet.rb', line 8 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_catalog(node = nil) ⇒ Object
Compile catalog for configured testnode.
@confdir defaults to '/etc/puppet'
@manifest defaults to @confdir + '/manifests/site.pp'
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/cucumber-puppet/puppet.rb', line 43 def compile_catalog( node = nil ) Puppet[:confdir] = @confdir Puppet[:manifest] = @manifest Puppet.parse_config unless node.is_a?(Puppet::Node) node = Puppet::Node.new(@facts['hostname'], :classes => @klass) node.merge(@facts) end begin # Compile our catalog begin @catalog = Puppet::Resource::Catalog.find(node.name, :use_node => node) rescue NameError @catalog = Puppet::Node::Catalog.find(node.name, :use_node => node) end rescue => detail if Puppet[:trace] puts detail.backtrace end if detail.is_a?(XMLRPC::FaultException) $stderr.puts detail. else $stderr.puts detail end exit 1 end end |
#debug ⇒ Object
Set Puppet’s log level to ‘debug’.
28 29 30 |
# File 'lib/cucumber-puppet/puppet.rb', line 28 def debug Puppet::Util::Log.level = :debug end |
#get_resource(title) ⇒ Object
Returns an Object with the given title from catalog.
74 75 76 |
# File 'lib/cucumber-puppet/puppet.rb', line 74 def get_resource(title) @catalog.resource(title) end |
#klass=(klass) ⇒ Object
Define Puppet classes to include in a feature’s testnode.
33 34 35 36 |
# File 'lib/cucumber-puppet/puppet.rb', line 33 def klass=(klass) # XXX sth like klass.split(/,/) and remove whitespace @klass = klass.to_a end |
#resource(title) ⇒ Object
XXX add deprecation warning for resource()
78 79 80 |
# File 'lib/cucumber-puppet/puppet.rb', line 78 def resource(title) get_resource(title) end |