diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-07-11 01:33:40 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-07-11 01:33:40 -0400 |
commit | 5c22a2a78960b4327fccfab5fc483e2761f93486 (patch) | |
tree | 08f35fccede7d049196a6ea0004ae6f81c5b46ac | |
parent | 4d2fb213b04a30a2d9e7b65244f4af38b2e183ad (diff) | |
download | puppet-tozt-5c22a2a78960b4327fccfab5fc483e2761f93486.tar.gz puppet-tozt-5c22a2a78960b4327fccfab5fc483e2761f93486.zip |
add helper for systemd overrides
-rw-r--r-- | modules/cron/manifests/init.pp | 17 | ||||
-rw-r--r-- | modules/duplicati/manifests/server.pp | 13 | ||||
-rw-r--r-- | modules/gitea/manifests/init.pp | 14 | ||||
-rw-r--r-- | modules/munin/manifests/node.pp | 19 | ||||
-rw-r--r-- | modules/postgres/manifests/init.pp | 13 | ||||
-rw-r--r-- | modules/systemd/manifests/override.pp | 13 |
6 files changed, 39 insertions, 50 deletions
diff --git a/modules/cron/manifests/init.pp b/modules/cron/manifests/init.pp index 86dcd13..0d390b6 100644 --- a/modules/cron/manifests/init.pp +++ b/modules/cron/manifests/init.pp @@ -1,6 +1,4 @@ class cron { - include systemd - $from = "${facts['networking']['hostname']}-cron" $password = secret::value('cron_email_password') @@ -13,15 +11,10 @@ class cron { content => template('cron/msmtprc'); '/etc/aliases': content => template('cron/aliases'); - '/etc/systemd/system/cronie.service.d': - ensure => directory; - '/etc/systemd/system/cronie.service.d/override.conf': - source => 'puppet:///modules/cron/override.conf', - require => File['/etc/systemd/system/cronie.service.d'], - notify => [ - Exec["/usr/bin/systemctl daemon-reload"], - Service['cronie'], - ]; + } + + systemd::override { "cronie": + source => 'puppet:///modules/cron/override.conf'; } service { 'cronie': @@ -29,7 +22,7 @@ class cron { enable => true, require => [ Package['cronie'], - File['/etc/systemd/system/cronie.service.d/override.conf'], + Systemd::Override['cronie'], Exec["/usr/bin/systemctl daemon-reload"], ]; } diff --git a/modules/duplicati/manifests/server.pp b/modules/duplicati/manifests/server.pp index f057426..4b5d1f5 100644 --- a/modules/duplicati/manifests/server.pp +++ b/modules/duplicati/manifests/server.pp @@ -1,6 +1,4 @@ class duplicati::server { - include systemd - package { [ "gtk-sharp-2", @@ -18,13 +16,8 @@ class duplicati::server { ] } - file { - '/etc/systemd/system/duplicati.service.d': - ensure => directory; - '/etc/systemd/system/duplicati.service.d/override.conf': - source => 'puppet:///modules/duplicati/override.conf', - notify => Exec['/usr/bin/systemctl daemon-reload'], - require => File['/etc/systemd/system/duplicati.service.d']; + systemd::override { "duplicati": + source => 'puppet:///modules/duplicati/override.conf'; } service { 'duplicati': @@ -32,7 +25,7 @@ class duplicati::server { enable => true, require => [ Package::Makepkg['duplicati-latest'], - File['/etc/systemd/system/duplicati.service.d/override.conf'], + Systemd::Override['duplicati'], Exec['/usr/bin/systemctl daemon-reload'], ]; } diff --git a/modules/gitea/manifests/init.pp b/modules/gitea/manifests/init.pp index a556eed..df30bbb 100644 --- a/modules/gitea/manifests/init.pp +++ b/modules/gitea/manifests/init.pp @@ -1,6 +1,4 @@ class gitea { - include systemd - package { "gitea": ensure => installed; } @@ -15,7 +13,7 @@ class gitea { enable => true, require => [ Package['gitea'], - File['/etc/systemd/system/gitea.service.d/override.conf'], + Systemd::Override['gitea'], Exec["/usr/bin/systemctl daemon-reload"], File['/media/persistent/gitea/custom/conf/app.ini'], ]; @@ -60,12 +58,6 @@ class gitea { owner => 'gitea', group => 'gitea', require => File['/media/persistent/gitea/custom/conf']; - '/etc/systemd/system/gitea.service.d': - ensure => directory; - '/etc/systemd/system/gitea.service.d/override.conf': - source => 'puppet:///modules/gitea/override.conf', - notify => Exec["/usr/bin/systemctl daemon-reload"], - require => File["/etc/systemd/system/gitea.service.d"]; '/usr/local/bin/github2gitea': content => template('gitea/github2gitea'), mode => "0755"; @@ -74,6 +66,10 @@ class gitea { mode => "0755"; } + systemd::override { "gitea": + source => 'puppet:///modules/gitea/override.conf'; + } + exec { "initialize gitea": provider => shell, command => 'su -p gitea /usr/local/bin/setup-gitea && systemctl restart gitea && /usr/local/bin/github2gitea', diff --git a/modules/munin/manifests/node.pp b/modules/munin/manifests/node.pp index b58d7c2..5a001cc 100644 --- a/modules/munin/manifests/node.pp +++ b/modules/munin/manifests/node.pp @@ -11,19 +11,16 @@ class munin::node { ], subscribe => [ File['/etc/munin/munin-node.conf'], - File['/etc/systemd/system/munin-node.service.d/override.conf'], + Systemd::Override['munin-node'], ]; } - file { - '/etc/munin/munin-node.conf': - content => template('munin/munin-node.conf'), - require => Package['munin-node']; - '/etc/systemd/system/munin-node.service.d': - ensure => directory; - '/etc/systemd/system/munin-node.service.d/override.conf': - source => 'puppet:///modules/munin/override.conf', - notify => Exec["/usr/bin/systemctl daemon-reload"], - require => File["/etc/systemd/system/munin-node.service.d"]; + file { '/etc/munin/munin-node.conf': + content => template('munin/munin-node.conf'), + require => Package['munin-node']; + } + + systemd::override { "munin-node": + source => 'puppet:///modules/munin/override.conf'; } } diff --git a/modules/postgres/manifests/init.pp b/modules/postgres/manifests/init.pp index 646196d..af60384 100644 --- a/modules/postgres/manifests/init.pp +++ b/modules/postgres/manifests/init.pp @@ -1,6 +1,4 @@ class postgres { - include systemd - $dbpath = "${persistent_data}/postgres" # lint:ignore:variable_scope package { "postgresql": @@ -22,12 +20,10 @@ class postgres { Package["postgresql"], File[$dbpath], ]; - "/etc/systemd/system/postgresql.service.d": - ensure => directory; - "/etc/systemd/system/postgresql.service.d/override.conf": - content => template('postgres/postgres-service'), - notify => Exec["/usr/bin/systemctl daemon-reload"], - require => File["/etc/systemd/system/postgresql.service.d"]; + } + + systemd::override { "postgresql": + content => template('postgres/postgres-service'); } exec { "fixup db path permissions": @@ -55,6 +51,7 @@ class postgres { enable => true, require => [ Package["postgresql"], + Systemd::Override['postgresql'], Exec["initialize db path"], ]; } diff --git a/modules/systemd/manifests/override.pp b/modules/systemd/manifests/override.pp new file mode 100644 index 0000000..976dc08 --- /dev/null +++ b/modules/systemd/manifests/override.pp @@ -0,0 +1,13 @@ +define systemd::override($source = undef, $content = undef) { + include systemd + + file { + "/etc/systemd/system/${name}.service.d": + ensure => directory; + "/etc/systemd/system/${name}.service.d/override.conf": + source => $source, + content => $content, + notify => Exec['/usr/bin/systemctl daemon-reload'], + require => File["/etc/systemd/system/${name}.service.d"]; + } +} |