Puppet Class: puppet::agent::bootstrap

Inherits:
puppet::params
Defined in:
manifests/agent/bootstrap.pp

Summary

Puppet bootstrap commands

Overview

Puppet bootstrap commands

Examples:

include puppet::agent::bootstrap

Parameters:

  • puppet_path (Stdlib::Unixpath) (defaults to: $puppet::params::puppet_path)
  • options (String) (defaults to: '--test')
  • hostprivkey (Stdlib::Unixpath) (defaults to: $puppet::params::hostprivkey)
  • hostcert (Stdlib::Unixpath) (defaults to: $puppet::params::hostcert)
  • certname (Optional[String]) (defaults to: undef)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'manifests/agent/bootstrap.pp', line 14

class puppet::agent::bootstrap (
  Stdlib::Unixpath $puppet_path = $puppet::params::puppet_path,
  String $options = '--test',
  Stdlib::Unixpath $hostprivkey = $puppet::params::hostprivkey,
  Stdlib::Unixpath $hostcert = $puppet::params::hostcert,
  Optional[String] $certname = undef,
) inherits puppet::params {
  # /opt/puppetlabs/puppet/bin/puppet agent --test
  exec {
    default:
      command => "${puppet_path} agent ${options}",
      returns => [0, 1, 2, 4, 6],
      ;
    'puppet-bootstrap-privkey':
      creates => $hostprivkey,
      ;
    'puppet-bootstrap-cert':
      creates => $hostcert,
      ;
  }

  # copy certname PEM file to clientcert PEM file
  if $certname {
    exec {
      default:
        path   => '/bin:/usr/bin',
        onlyif => "test -f ${certname}.pem";
      "cp -a ${certname}.pem ${hostcert}":
        cwd     => $puppet::params::certdir,
        creates => $hostcert,
        require => Exec['puppet-bootstrap-cert'];
      "cp -a ${certname}.pem ${hostprivkey}":
        cwd     => $puppet::params::privatekeydir,
        creates => $hostprivkey,
        require => Exec['puppet-bootstrap-privkey'];
    }
  }
}