From e1c6349ec0d9aa6cb7d1690edf0416ddd3709d8a Mon Sep 17 00:00:00 2001 From: Hendrik Jäger Date: Fri, 1 Jul 2022 22:15:04 +0200 Subject: refactor --- manifests/init.pp | 13 ++++++----- manifests/network.pp | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 manifests/network.pp (limited to 'manifests') 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', + ; + } +} -- cgit v1.2.3