diff --git a/cron/config/file.sls b/cron/config/file.sls index 56fc6b8..83270e6 100644 --- a/cron/config/file.sls +++ b/cron/config/file.sls @@ -25,7 +25,7 @@ cron.{{ task }}: {%- endfor %} {%- for env, env_options in cron.get('env', {}). items() %} -{%- set env_type = env_options.type|d('present') %} +{%- set env_type = env_options.type|d('present') %} cron.{{ env }}: cron.env_{{ env_type }}: diff --git a/cron/saltcheck-tests/config/file.tst b/cron/saltcheck-tests/config/file.tst index 23f0a16..527f10f 100644 --- a/cron/saltcheck-tests/config/file.tst +++ b/cron/saltcheck-tests/config/file.tst @@ -45,3 +45,15 @@ validate_cron.{{ task }}_{{ section }}: {%- endif %} {%- endfor %} + +{%- for env, env_options in cron.get('env', {}). items() %} +{%- set env_type = env_options.type|d('present') %} + +validate_cron.{{ env }}_{{ env_type }}: + module_and_function: cron.raw_cron + args: + - {{ env_options.user|d('root') }} + assertion: {{ 'assertNotIn' if env_type == 'absent' else 'assertIn' }} + expected-return: '{{ env_options.name }}={{ env_options.value }}' + +{%- endfor %} diff --git a/test/salt/pillar/cron.sls b/test/salt/pillar/cron.sls index d7f6a77..fdf45cc 100644 --- a/test/salt/pillar/cron.sls +++ b/test/salt/pillar/cron.sls @@ -46,3 +46,19 @@ cron: minute: random hour: 1 commented: true + env: + env1: + type: present + name: PATH + value: /usr/local/bin:/usr/bin:/bin:/usr/games + user: root + env2: + type: present + name: MAILTO + value: example@example.com + user: root + env3: + type: absent + name: LANG + value: en_GB.UTF-8 + user: root