diff options
author | Hendrik Jäger <gitcommit@henk.geekmail.org> | 2022-07-01 22:15:04 +0200 |
---|---|---|
committer | Hendrik Jäger <gitcommit@henk.geekmail.org> | 2022-07-01 22:25:22 +0200 |
commit | e1c6349ec0d9aa6cb7d1690edf0416ddd3709d8a (patch) | |
tree | e443185df7b20f11ab83f81057f5951c5ec0e49e /manifests | |
parent | bfc65b39a1c85b67c44817cadb6de2a2fb2505a0 (diff) |
refactor
Diffstat (limited to 'manifests')
-rw-r--r-- | manifests/init.pp | 13 | ||||
-rw-r--r-- | manifests/network.pp | 64 |
2 files changed, 71 insertions, 6 deletions
diff --git a/manifests/init.pp b/manifests/init.pp index b7765a5..e9f962a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,10 +1,11 @@ class henks_ircservices ( + Array $networks ) { - user { - 'irc-services': - ensure => present, - managehome => true, - password => '!', - ; + $networks.each |$network| { + henks_ircservices::network { + $network['name']: + run_user => $network.dig('system_user').lest | | { "irc-services-${network['name']}" }, + ; + } } } diff --git a/manifests/network.pp b/manifests/network.pp new file mode 100644 index 0000000..1e432ac --- /dev/null +++ b/manifests/network.pp @@ -0,0 +1,64 @@ +define henks_ircservices::network ( + String $run_user = "irc-services-${name}", + String $network_name = $name, +) { + $service_base = "/etc/s6-services/irc-services-${network_name}/" + + user { + $run_user: + ensure => present, + password => '!', + managehome => true, + ; + } + + file { + $service_base: + ensure => directory, + ; + "${service_base}/run": + ensure => present, + content => epp( + 'henks_ircservices/etc/s6-services/irc-services/run.epp', + { + 'network_name' => $network_name, + 'run_user' => $run_user, + }, + ), + mode => '0755', + ; + "${service_base}/timeout-kill": + ensure => present, + content => '0', + ; + "${service_base}/log/": + ensure => directory, + ; + "${service_base}/log/run": + ensure => present, + content => epp( + 'henks_ircservices/etc/s6-services/irc-services/log/run.epp', + { + 'network_name' => $network_name, + }, + ), + mode => '0755', + ; + "/var/log/s6/irc-services-${network_name}/": + ensure => directory, + mode => '0700', + ; + "/var/log/s6/irc-services-${network_name}/logs/": + ensure => directory, + mode => '0700', + ; + } + + service { + "irc-services-${network_name}": + ensure => running, + enable => true, + provider => 's6', + ; + } +} |