From 8845b3c50fe22a45f5a57713bce39132b4d13b96 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Mon, 14 Oct 2019 13:57:31 +0100 Subject: [PATCH] test(saltcheck): use local `map.jinja` to workaround missing `tpldata` --- cron/saltcheck-tests/config.tst | 2 +- cron/saltcheck-tests/install.tst | 2 +- cron/saltcheck-tests/map.jinja | 47 ++++++++++++++++++++++++++++++++ cron/saltcheck-tests/service.tst | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 cron/saltcheck-tests/map.jinja diff --git a/cron/saltcheck-tests/config.tst b/cron/saltcheck-tests/config.tst index ad89650..e8802bc 100644 --- a/cron/saltcheck-tests/config.tst +++ b/cron/saltcheck-tests/config.tst @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from "cron/map.jinja" import cron_settings with context %} +{%- from "cron/saltcheck-tests/map.jinja" import cron_settings with context %} {%- if 'tasks' in cron_settings %} {%- for task,task_options in cron_settings.tasks.items() %} diff --git a/cron/saltcheck-tests/install.tst b/cron/saltcheck-tests/install.tst index 09c953b..8547f55 100644 --- a/cron/saltcheck-tests/install.tst +++ b/cron/saltcheck-tests/install.tst @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from "cron/map.jinja" import cron_settings with context %} +{%- from "cron/saltcheck-tests/map.jinja" import cron_settings with context %} verify_cron.install: module_and_function: pkg.version diff --git a/cron/saltcheck-tests/map.jinja b/cron/saltcheck-tests/map.jinja new file mode 100644 index 0000000..181dff6 --- /dev/null +++ b/cron/saltcheck-tests/map.jinja @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +# vim: ft=jinja + +{#- Start imports as #} +{%- import_yaml "cron" ~ "/defaults.yaml" as default_settings %} +{%- import_yaml "cron" ~ "/osarchmap.yaml" as osarchmap %} +{%- import_yaml "cron" ~ "/osfamilymap.yaml" as osfamilymap %} +{%- import_yaml "cron" ~ "/osmap.yaml" as osmap %} +{%- import_yaml "cron" ~ "/osfingermap.yaml" as osfingermap %} + +{#- Retrieve the config dict only once #} +{%- set _config = salt['config.get']("cron", default={}) %} + +{%- set defaults = salt['grains.filter_by']( + default_settings, + default="cron", + merge=salt['grains.filter_by']( + osarchmap, + grain='osarch', + merge=salt['grains.filter_by']( + osfamilymap, + grain='os_family', + merge=salt['grains.filter_by']( + osmap, + grain='os', + merge=salt['grains.filter_by']( + osfingermap, + grain='osfinger', + merge=salt['grains.filter_by']( + _config, + default='lookup' + ) + ) + ) + ) + ) + ) +%} + +{%- set config = salt['grains.filter_by']( + {'defaults': defaults}, + default='defaults', + merge=_config + ) +%} + +{%- set cron = config %} diff --git a/cron/saltcheck-tests/service.tst b/cron/saltcheck-tests/service.tst index 1e46a94..43e5baa 100644 --- a/cron/saltcheck-tests/service.tst +++ b/cron/saltcheck-tests/service.tst @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # vim: ft=sls -{%- from "cron/map.jinja" import cron_settings with context %} +{%- from "cron/saltcheck-tests/map.jinja" import cron_settings with context %} cron.service: {%- if 'enabled' not in cron_settings or ( 'enabled' in cron_settings and cron_settings.enabled ) %}