Puppet Class: masterless

Defined in:
manifests/init.pp

Overview

Sets up puppet to run masterlessly via a systemd timer

Parameters:

  • repodir (Any) (defaults to: '/opt/halyard/repo')
  • bindir (Any) (defaults to: '/usr/local/bin')
  • bootdelay (Any) (defaults to: '1min')
  • frequency (Any) (defaults to: '1hour')


3
4
5
6
7
8
9
10
11
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
# File 'manifests/init.pp', line 3

class masterless(
    $repodir = '/opt/halyard/repo',
    $bindir = '/usr/local/bin',
    $bootdelay = '1min',
    $frequency = '1hour'
) {
    file { '/etc/systemd/system/multi-user.target.wants/puppet.service':
        ensure => absent
    }

    file { "${bindir}/puppet-run":
        ensure => link,
        target => "${repodir}/meta/puppet-run"
    }

    file { '/etc/systemd/system/puppet-run.service':
        ensure  => 'file',
        content => template('masterless/puppet-run.service.erb'),
        notify  =>  Exec['Puppet-run refresh systemd']
    }

    file { '/etc/systemd/system/puppet-run.timer':
        ensure  => 'file',
        content => template('masterless/puppet-run.timer.erb'),
        notify  =>  Exec['Puppet-run refresh systemd']
    }

    file { '/etc/systemd/system/multi-user.target.wants/puppet-run.timer':
        ensure  => 'link',
        target  => '/etc/systemd/system/puppet-run.timer',
        require => File['/etc/systemd/system/puppet-run.timer'],
        notify  =>  Exec['Puppet-run refresh systemd']
    }

    exec { 'Puppet-run refresh systemd':
        command     => 'systemctl daemon-reload',
        refreshonly => true,
        path        => ['/usr/bin', '/bin']
    }
    ~> exec { 'Start puppet-run':
        command     => 'systemctl start puppet-run.timer',
        refreshonly => true,
        path        => ['/usr/bin', '/bin']
    }
}