Class: NodeSpec::Provisioning::Puppet
- Inherits:
-
Object
- Object
- NodeSpec::Provisioning::Puppet
- Defined in:
- lib/nodespec/provisioning/puppet.rb
Constant Summary collapse
- HIERADATA_DIRNAME =
'puppet_hieradata'
- HIERA_CONFIG_FILENAME =
'puppet_hiera.yaml'
- HIERA_DEFAULT_HIERARCHY =
'common'
- HIERA_CONFIG_TEMPLATE =
<<-EOS :backends: - yaml :yaml: :datadir: <%= hieradata_dir %> :hierarchy: - #{HIERA_DEFAULT_HIERARCHY} EOS
Instance Method Summary collapse
-
#initialize(node) ⇒ Puppet
constructor
A new instance of Puppet.
- #puppet_apply_execute(snippet, options = []) ⇒ Object
- #puppet_apply_manifest(manifest_file, options = []) ⇒ Object
- #set_facts(facts) ⇒ Object
- #set_hieradata(values) ⇒ Object
- #set_modulepaths(*paths) ⇒ Object
Constructor Details
#initialize(node) ⇒ Puppet
Returns a new instance of Puppet.
19 20 21 |
# File 'lib/nodespec/provisioning/puppet.rb', line 19 def initialize(node) @node = node end |
Instance Method Details
#puppet_apply_execute(snippet, options = []) ⇒ Object
40 41 42 |
# File 'lib/nodespec/provisioning/puppet.rb', line 40 def puppet_apply_execute(snippet, = []) @node.execute("#{()} -e #{snippet.shellescape}") end |
#puppet_apply_manifest(manifest_file, options = []) ⇒ Object
44 45 46 |
# File 'lib/nodespec/provisioning/puppet.rb', line 44 def puppet_apply_manifest(manifest_file, = []) @node.execute("#{()} #{manifest_file.shellescape}") end |
#set_facts(facts) ⇒ Object
27 28 29 |
# File 'lib/nodespec/provisioning/puppet.rb', line 27 def set_facts(facts) @facts = facts.reduce("") { |fact, pair| "FACTER_#{pair[0]}=#{pair[1].shellescape} #{fact}" } end |
#set_hieradata(values) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/nodespec/provisioning/puppet.rb', line 31 def set_hieradata(values) unless values.empty? hieradata_dir = @node.create_directory(HIERADATA_DIRNAME) @node.create_file("#{HIERADATA_DIRNAME}/#{HIERA_DEFAULT_HIERARCHY}.yaml", YAML.dump(values)) hiera_config = @node.create_file(HIERA_CONFIG_FILENAME, ERB.new(HIERA_CONFIG_TEMPLATE).result(binding)) @hiera_option = "--hiera_config #{hiera_config}" end end |
#set_modulepaths(*paths) ⇒ Object
23 24 25 |
# File 'lib/nodespec/provisioning/puppet.rb', line 23 def set_modulepaths(*paths) @modulepath_option = "--modulepath #{paths.join(':').shellescape}" unless paths.empty? end |