class NodeSpec::Provisioning::Puppet
Constants
- HIERADATA_DIRNAME
- HIERA_CONFIG_FILENAME
- HIERA_CONFIG_TEMPLATE
- HIERA_DEFAULT_HIERARCHY
Public Class Methods
new(node)
click to toggle source
# File lib/nodespec/provisioning/puppet.rb, line 19 def initialize(node) @node = node end
Public Instance Methods
puppet_apply_execute(snippet, options = [])
click to toggle source
# File lib/nodespec/provisioning/puppet.rb, line 40 def puppet_apply_execute(snippet, options = []) @node.execute("#{group_command_options(options)} -e #{snippet.shellescape}") end
puppet_apply_manifest(manifest_file, options = [])
click to toggle source
# File lib/nodespec/provisioning/puppet.rb, line 44 def puppet_apply_manifest(manifest_file, options = []) @node.execute("#{group_command_options(options)} #{manifest_file.shellescape}") end
set_facts(facts)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/nodespec/provisioning/puppet.rb, line 23 def set_modulepaths(*paths) @modulepath_option = "--modulepath #{paths.join(':').shellescape}" unless paths.empty? end
Private Instance Methods
group_command_options(options)
click to toggle source
# File lib/nodespec/provisioning/puppet.rb, line 50 def group_command_options(options) %Q[#{@facts}puppet apply #{@modulepath_option} #{@hiera_option} #{options.join(' ')}] end