From 2c5540f7dfbf23453b3caf99b7c935d6939d0a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 18 Sep 2023 20:12:27 +0200 Subject: Document stuff. --- README.md | 9 ++++++++- manifests/init.pp | 11 ++++++++++- manifests/setup.pp | 14 +++++++++----- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 015d9de..4364388 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,11 @@ Envvar Module for managing global environment modules. -Currently uses `/etc/environment`, so requires logind. +On systemd systems, this module takes control over +`/etc/environment`. This means that `logind` must be in use. + +Currently no other system is supported. + +The key `environment` will be looked up through hiera as a hash, +where each key will be used as an environment variable, and each +value will be the corresponding value. diff --git a/manifests/init.pp b/manifests/init.pp index b6cc673..b807405 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,12 +1,21 @@ # Manage a single global environment variables. +# +# @param key +# Environment variable to set. +# @param value +# Value of the set environment variable. +# @param order +# Relative order to all other environment variables. define envvar ( $value, String $key = $name, + Integer[1, 999] $order = 100, ) { include ::envvar::setup - concat::fragment { "User environment ${name}": + concat::fragment { "/etc/environment - ${name}": target => '/etc/environment', content => "${key}=${value}\n", + order => $order, } } diff --git a/manifests/setup.pp b/manifests/setup.pp index 0891c55..acaba6d 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -1,11 +1,15 @@ -class envvar::setup ( -) { +# Setup "infrastructure" for global environment variables. +# +# @api private +class envvar::setup { concat { '/etc/environment': ensure => 'present', + order => 'numeric', } - concat::fragment { '000 header': + concat::fragment { '/etc/environment -- header': target => '/etc/environment', + order => 0, content => @(EOF) # File managed by Puppet # Local changes will get overwritten. @@ -13,9 +17,9 @@ class envvar::setup ( } lookup('environment', undef, 'hash', {}).map |$key, $value| { - envvar{ $key: + envvar { $key: value => $value, } } - + } -- cgit v1.2.3