From ad4b68911fa36d98b7268e52192ce404f3db40c8 Mon Sep 17 00:00:00 2001 From: Arne Teuke Date: Mon, 10 Mar 2025 15:13:46 +0100 Subject: [PATCH] add user control --- manifests/main/service.pp | 1 + manifests/main/user.pp | 24 ++++++++++++++++++++++++ manifests/params.pp | 10 ++++++++++ 3 files changed, 35 insertions(+) create mode 100644 manifests/main/user.pp diff --git a/manifests/main/service.pp b/manifests/main/service.pp index 3ad9bdd..bda2929 100644 --- a/manifests/main/service.pp +++ b/manifests/main/service.pp @@ -7,6 +7,7 @@ class alloy_cd::main::service ( ) inherits alloy_cd::params { require alloy_cd::main::files + require alloy_cd::main::user service { $ay_service: ensure => running, diff --git a/manifests/main/user.pp b/manifests/main/user.pp new file mode 100644 index 0000000..0a8091f --- /dev/null +++ b/manifests/main/user.pp @@ -0,0 +1,24 @@ +## alloy_cd::main::user.pp +# Module name: alloy_cd +# Author: Arne Teuke (arne_teuke@confdroid.com) +# @summary Class manages the alloy user +############################################################################### +class alloy_cd::main::user ( + +) inherits alloy_cd::params { + if $ay_manage_user == true { + user { $ay_user: + ensure => present, + name => $ay_user, + allowdupe => false, + groups => $ay_groups, + managehome => false, + shell => $ay_user_shell, + } + + group { $ay_user: + ensure => present, + allowdupe => false, + } + } +} diff --git a/manifests/params.pp b/manifests/params.pp index 0f926e0..a69ec2d 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -10,6 +10,10 @@ # @param [boolean] ay_manage_prom whether to manage metric forwarding # @param [string] ay_prom_url the url where alloy will send metrics # @param [array] ay_log_targets the logging targets +# @param [boolean] ay_manage_user whether to manage user settings +# @param [string] ay_user the alloy user name +# @param [array] ay_groups which groups the user should be in +# @param [string] ay_user_shell which shell to use # @summary Class contains all parameters for the alloy_cd module. ############################################################################## class alloy_cd::params ( @@ -28,6 +32,12 @@ class alloy_cd::params ( Boolean $ay_manage_prom = true, String $ay_prom_url = 'https://prometheus.example.net/api/v1/write', +# user + Boolean $ay_manage_user = true, + String $ay_user = 'alloy', + Array $ay_groups = ['wheel','adm'], + String $ay_user_shell = '/sbin/nologin', + ) { # service $ay_service = 'alloy'