Puppet Class: systemd::timesyncd

Defined in:
modules/systemd/manifests/timesyncd.pp

Overview

Parameters:

  • ntp_servers (Array[Stdlib::Host])

    list of ntpr_servers

  • ensure (Wmflib::Ensure) (defaults to: 'present')

    if we should ensure the class



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
# File 'modules/systemd/manifests/timesyncd.pp', line 4

class systemd::timesyncd (
    Array[Stdlib::Host] $ntp_servers,
    Wmflib::Ensure      $ensure = 'present',
) {
    # only purge ntp if we are ensuring timesyncd
    if $ensure == 'present' {
        ensure_packages(['ntp'], {'ensure' => 'purged'})
        # On systemd >247.3-6~bpo10+1 at least this service is handled by the systemd-timesyncd package
        # before it was installed by systemd
        if (debian::codename::ge('bullseye')) {
            ensure_packages(['systemd-timesyncd'])
            Package['systemd-timesyncd'] -> File['/etc/systemd/timesyncd.conf']
        }
    }

    file { '/etc/systemd/timesyncd.conf':
        ensure  => stdlib::ensure($ensure, 'file'),
        mode    => '0444',
        owner   => 'root',
        group   => 'root',
        content => template('systemd/timesyncd.conf.erb'),
    }

    # Ideally we could just rely on stdlib::ensure below. However this causes an error when:
    # * ensure => 'absent'
    # * debian::codename::ge bullseye
    # As in this case there is no systemd-timesync service available to manage.
    if (defined(Package['systemd-timesyncd']) or $ensure == 'present') {
        service { 'systemd-timesyncd':
            ensure => stdlib::ensure($ensure, 'service'),
            enable => true,
        }
        File['/etc/systemd/timesyncd.conf'] ~> Service['systemd-timesyncd']
    }
}