Puppet Class: puppet::agent

Defined in:
modules/puppet/manifests/agent.pp

Summary

install and configure puppet agent

Overview

Parameters:

  • manage_ca_file (Boolean) (defaults to: false)

    if true manage the puppet ca file

  • ca_file_path (Stdlib::Unixpath) (defaults to: '/var/lib/puppet/ssl/certs/ca.pem')

    the path to the ca file

  • ca_server (Optional[String[1]]) (defaults to: undef)

    the ca server

  • server (Stdlib::Host) (defaults to: 'puppet')

    the puppet server

  • certname (Optional[String[1]]) (defaults to: undef)

    the agent certname

  • dns_alt_names (Array[Stdlib::Fqdn]) (defaults to: [])

    a list of dns alt names

  • environment (Optional[String[1]]) (defaults to: undef)

    the agent environment

  • serialization_format (Enum['pson', 'json', 'msgpack']) (defaults to: 'json')

    the serilasation format of catalogs

  • ca_source (Optional[Stdlib::Filesource]) (defaults to: undef)

    to source of the CA file

  • certificate_revocation (Optional[Enum['chain', 'leaf']]) (defaults to: undef)

    The level of certificate revocation to perform



12
13
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'modules/puppet/manifests/agent.pp', line 12

class puppet::agent (
    Boolean                         $manage_ca_file         = false,
    Stdlib::Unixpath                $ca_file_path           = '/var/lib/puppet/ssl/certs/ca.pem',
    Optional[String[1]]             $ca_server              = undef,
    Stdlib::Host                    $server                 = 'puppet',
    Optional[String[1]]             $certname               = undef,
    Array[Stdlib::Fqdn]             $dns_alt_names          = [],
    Optional[String[1]]             $environment            = undef,
    Enum['pson', 'json', 'msgpack'] $serialization_format   = 'json',
    Optional[Stdlib::Filesource]    $ca_source              = undef,
    Optional[Enum['chain', 'leaf']] $certificate_revocation = undef,
) {
    # augparse is required to resolve the augeasversion in facter3
    # facter needs virt-what for proper "virtual"/"is_virtual" resolution
    # TODO: use puppet-agent package name when everything is on puppet7
    # puppet is a transition package
    ensure_packages(['facter', 'puppet', 'augeas-tools', 'virt-what'])

    if $manage_ca_file {
        unless $ca_source {
          fail('require ca_source when manage_ca: true')
        }
        file { $ca_file_path:
            ensure => file,
            owner  => 'puppet',
            group  => 'puppet',
            mode   => '0644',
            source => $ca_source,
        }
    }
    file { '/etc/puppet/puppet.conf':
        ensure => 'file',
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
        notify => Exec['compile puppet.conf'],
    }

    file { '/etc/puppet/puppet.conf.d/':
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0550',
    }

    file { ['/etc/puppetlabs/','/etc/puppetlabs/facter/']:
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0555',
    }

    file { '/etc/puppetlabs/facter/facter.conf':
        ensure => 'file',
        owner  => 'root',
        group  => 'root',
        mode   => '0444',
        source => 'puppet:///modules/puppet/facter.conf',
    }

    puppet::config { 'main':
        prio    => 10,
        content => template('puppet/main.conf.erb'),
    }

    # Compile /etc/puppet/puppet.conf from individual files in /etc/puppet/puppet.conf.d
    exec { 'compile puppet.conf':
        path        => '/usr/bin:/bin',
        command     => 'cat /etc/puppet/puppet.conf.d/??-*.conf > /etc/puppet/puppet.conf',
        refreshonly => true,
    }

    ## do not use puppet agent, use a cron-based puppet-run instead
    service { 'puppet':
        ensure => stopped,
        enable => false,
    }
}