From 1200d3528a3a56b464eca4ec836af003383ddba1 Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Tue, 28 Nov 2023 21:03:38 +0200 Subject: [PATCH] add users creation --- manifests/init.pp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 20c2c8f..d6e952e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -51,6 +51,9 @@ # [*vapid_public_key*] # String with VAPID public key # +# [*users*] +# List of hashes with users information. +# class mastodon ( String $ensure = 'present', String $hostname = 'mastodon.example.org', @@ -90,6 +93,7 @@ class mastodon ( 'IP_RETENTION_PERIOD' => 31556952, 'SESSION_RETENTION_PERIOD' => 31556952, }, + Array $users = [], ) { case $ensure { default: { @@ -427,5 +431,24 @@ class mastodon ( active => true, enable => true, } - # create admin user + $users.each | $user | { + if ($user['confirmed']) { + $confirmed = '--confirmed' + } else { + $confirmed = '' + } + exec { "create_user_${user['username']}": + command => "${mastodon_home}/live/bin/tootctl accounts create '${user['username']}' --email '${user['email']}' ${confirmed} --role '${user['role']}' > '${mastodon_home}/create_user_${user['username']}'", + creates => "${mastodon_home}/create_user_${user['username']}", + path => "${mastodon_home}/.rbenv/shims:${mastodon_home}/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + environment => [ + 'RAILS_ENV=production', + ], + user => $mastodon_user, + group => $mastodon_group, + cwd => "${mastodon_home}/live", + timeout => 0, + require => File["${mastodon_home}/live/.env.production"], + } + } }