From f341fae5472513454a68fe882b8800857192261d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Tue, 28 Mar 2017 11:48:57 +0200 Subject: [PATCH] add: systemd module for executing daemon-reload This change adds a new resource type that manages a given unit file and triggers a systemd daemon-reload when any of the files have been managed (but before any of their dependencies, i.e. services, are managed). Change-Id: I3ec4a38cfa09c6971269a1698d38af8b3b79d7ed --- environments/production/manifests/gigi.pp | 4 ++-- environments/production/manifests/gitweb.pp | 10 +++++----- environments/production/manifests/site.pp | 4 ++-- modules/systemd/manifests/init.pp | 6 ++++++ modules/systemd/manifests/unit_file.pp | 18 ++++++++++++++++++ 5 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 modules/systemd/manifests/init.pp create mode 100644 modules/systemd/manifests/unit_file.pp diff --git a/environments/production/manifests/gigi.pp b/environments/production/manifests/gigi.pp index 57c602f..80bb50a 100644 --- a/environments/production/manifests/gigi.pp +++ b/environments/production/manifests/gigi.pp @@ -124,7 +124,7 @@ if $signerLocation == 'self' { require => Exec['apt_update'] } $cass_ip = $ips[cassiopeia] - file {'/etc/systemd/system/tcpserial.service': + systemd::unit_file {'tcpserial.service': ensure => 'file', content => epp('gigi/tcpserial'), require => Package['tcpserial'] @@ -184,7 +184,7 @@ if $signerLocation == 'self' { source => 'puppet:///modules/cassiopeia/signer_client.key' } - file { '/etc/systemd/system/cassiopeia-client.service': + systemd::unit_file { 'cassiopeia-client.service': source => 'puppet:///modules/gigi/cassiopeia-client.service', ensure => 'present' } -> diff --git a/environments/production/manifests/gitweb.pp b/environments/production/manifests/gitweb.pp index a13d2a6..ade2708 100644 --- a/environments/production/manifests/gitweb.pp +++ b/environments/production/manifests/gitweb.pp @@ -20,12 +20,12 @@ node gitweb { group => 'git', before => Service['gitweb.service'] } - file{ '/etc/systemd/system/git.socket': + systemd::unit_file {'git.socket': ensure => 'file', source => 'puppet:///modules/gitweb/git.socket', before => Service['git.socket'] } - file{ '/etc/systemd/system/git@.service': + systemd::unit_file {'git@.service': ensure => 'file', source => 'puppet:///modules/gitweb/git@.service', before => Service['git.socket'] @@ -35,7 +35,7 @@ node gitweb { provider => 'systemd', enable => true } - file{ '/etc/systemd/system/gitweb.service': + systemd::unit_file {'gitweb.service': ensure => 'file', source => 'puppet:///modules/gitweb/gitweb.service', notify => Service['gitweb.service'] @@ -59,7 +59,7 @@ node gitweb { file{ '/etc/systemd/system/fcgiwrap.socket.d': ensure => 'directory' } - file{ '/etc/systemd/system/fcgiwrap.socket.d/ListenStream.conf': + systemd::unit_file {'fcgiwrap.socket.d/ListenStream.conf': ensure => 'file', source => 'puppet:///modules/gitweb/fcgiwrap-ListenStream.conf', notify => Service['fcgiwrap.socket'] @@ -67,7 +67,7 @@ node gitweb { file{ '/etc/systemd/system/fcgiwrap.service.d': ensure => 'directory' } - file{ '/etc/systemd/system/fcgiwrap.service.d/sandbox.conf': + systemd::unit_file {'fcgiwrap.service.d/sandbox.conf': ensure => 'file', source => 'puppet:///modules/gitweb/fcgiwrap-sandbox.conf', notify => Service['fcgiwrap.socket'] diff --git a/environments/production/manifests/site.pp b/environments/production/manifests/site.pp index 282d200..34e30d0 100644 --- a/environments/production/manifests/site.pp +++ b/environments/production/manifests/site.pp @@ -31,7 +31,7 @@ if $signerLocation == 'self' { require => Exec['apt_update'] } $cass_ip=''; - file {'/etc/systemd/system/tcpserial.service': + systemd::unit_file {'tcpserial.service': ensure => 'file', content => epp('gigi/tcpserial'), require => Package['tcpserial'] @@ -99,7 +99,7 @@ if $signerLocation == 'self' { content => epp('gigi/cassiopeia-client-conf'), } - file {'/etc/systemd/system/cassiopeia-signer.service': + systemd::unit_file {'cassiopeia-signer.service': ensure => 'file', source => 'puppet:///modules/gigi/cassiopeia-signer.service', }-> diff --git a/modules/systemd/manifests/init.pp b/modules/systemd/manifests/init.pp new file mode 100644 index 0000000..ff051af --- /dev/null +++ b/modules/systemd/manifests/init.pp @@ -0,0 +1,6 @@ +class systemd (){ + exec {'systemctl-daemon-reload': + command => '/bin/systemctl daemon-reload', + refreshonly => true + } +} \ No newline at end of file diff --git a/modules/systemd/manifests/unit_file.pp b/modules/systemd/manifests/unit_file.pp new file mode 100644 index 0000000..855c1e9 --- /dev/null +++ b/modules/systemd/manifests/unit_file.pp @@ -0,0 +1,18 @@ +define systemd::unit_file( + $ensure = file, + $path = '/etc/systemd/system', + $content = undef, + $source = undef, +) { + include ::systemd + + file { "${path}/${title}": + ensure => $ensure, + content => $content, + source => $source, + owner => 'root', + group => 'root', + mode => '0644', + notify => Exec['systemctl-daemon-reload'], + } +} -- 2.39.2