From: Peter Palfrader Date: Mon, 17 Jul 2017 09:29:35 +0000 (+0200) Subject: Add systemd override unit X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=162fa1aabf5fc2da1414e56d1c5c4960de579d82;p=mirror%2Fdsa-puppet.git Add systemd override unit --- diff --git a/modules/systemd/manifests/override.pp b/modules/systemd/manifests/override.pp new file mode 100644 index 000000000..7492a5574 --- /dev/null +++ b/modules/systemd/manifests/override.pp @@ -0,0 +1,44 @@ +define systemd::override ( + $source=undef, + $content=undef, + $ensure=present +) { + + $dir = "/etc/systemd/system/${name}.service.d" + $dest = "${dir}/override.conf" + case $ensure { + present: { + if ! ($source or $content) { + fail ( "No configuration found for ${name}" ) + } + + file { "${dir}": + ensure => directory, + mode => '0755' + } + if $content { + file { "${dest}": + ensure => $ensure, + content => $content, + notify => Exec['systemctl daemon-reload'], + } + } elsif $source { + file { "${dest}": + ensure => $ensure, + source => $source, + notify => Exec['systemctl daemon-reload'], + } + } + } + absent: { + file { "${dest}": + ensure => $ensure, + notify => Exec['service apache2 reload'], + } + file { "${dir}": + ensure => $ensure + } + } + default: { fail ( "Unknown ensure value: '$ensure'" ) } + } +}