Method: Beaker::DSL::InstallUtils#configure_puppet_on

Defined in:
lib/beaker/dsl/install_utils.rb

#configure_puppet_on(host, opts = {}) ⇒ Object

Configure puppet.conf on the given host based upon a provided hash

Examples:

will configure /etc/puppet.conf on the puppet master.

config = {
  'main' => {
    'server'   => 'testbox.test.local',
    'certname' => 'testbox.test.local',
    'logdir'   => '/var/log/puppet',
    'vardir'   => '/var/lib/puppet',
    'ssldir'   => '/var/lib/puppet/ssl',
    'rundir'   => '/var/run/puppet'
  },
  'agent' => {
    'environment' => 'dev'
  }
}
configure_puppet(master, config)

Parameters:

  • host (Host)

    The host to configure puppet.conf on

  • opts (Hash{Symbol=>String}) (defaults to: {})

Options Hash (opts):

  • :main (Hash{String=>String})

    configure the main section of puppet.conf

  • :agent (Hash{String=>String})

    configure the agent section of puppet.conf

Returns:

  • nil



771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/beaker/dsl/install_utils.rb', line 771

def configure_puppet_on(host, opts = {})
  if host['platform'] =~ /windows/
    puppet_conf = host.puppet['config']
    conf_data = ''
    opts.each do |section,options|
      conf_data << "[#{section}]`n"
      options.each do |option,value|
        conf_data << "#{option}=#{value}`n"
      end
      conf_data << "`n"
    end
    on host, powershell("\$text = \\\"#{conf_data}\\\"; Set-Content -path '#{puppet_conf}' -value \$text")
  else
    puppet_conf = host.puppet['config']
    conf_data = ''
    opts.each do |section,options|
      conf_data << "[#{section}]\n"
      options.each do |option,value|
        conf_data << "#{option}=#{value}\n"
      end
      conf_data << "\n"
    end
    on host, "echo \"#{conf_data}\" > #{puppet_conf}"
  end
end