From 12cee122279fc0abe113d35d59b626e2f94913ae Mon Sep 17 00:00:00 2001 From: Gino Naumann Date: Fri, 1 Nov 2019 08:38:15 +0100 Subject: [PATCH] feat(cron.env): add env option in cron-formula --- cron/config/file.sls | 13 +++++++++++++ pillar.example | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/cron/config/file.sls b/cron/config/file.sls index 2da2ae1..56fc6b8 100644 --- a/cron/config/file.sls +++ b/cron/config/file.sls @@ -23,3 +23,16 @@ cron.{{ task }}: {%- endif %} {%- endfor %} + +{%- for env, env_options in cron.get('env', {}). items() %} +{%- set env_type = env_options.type|d('present') %} + +cron.{{ env }}: + cron.env_{{ env_type }}: + - name: {{ env_options.name }} + {%- if env_type == 'present' %} + - value: {{ env_options.value }} + {%- endif %} + - user: {{ env_options.user|d('root') }} + +{%- endfor %} diff --git a/pillar.example b/pillar.example index 780bebd..465c298 100644 --- a/pillar.example +++ b/pillar.example @@ -35,3 +35,19 @@ cron: minute: '*/5' hour: '*' comment: comment4 + env: + env1: + type: present # Default + name: PATH + value: /usr/local/bin:/usr/bin:/bin:/usr/games + user: root # Default + env2: + type: absent + name: MAILTO + value: example@example.com # not needed + user: root # Default + env3: + type: absent + name: LANG + value: en_GB.UTF-8 + user: root