From b23b44867e62fd1cd89ccf37a06797f4f1678a5f Mon Sep 17 00:00:00 2001 From: Nicolas Rodriguez Date: Wed, 15 May 2019 23:14:24 +0200 Subject: [PATCH] feat(pillar): use config.get instead of pillar.get --- rkhunter/map.jinja | 48 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/rkhunter/map.jinja b/rkhunter/map.jinja index 32b2174..4888b8f 100644 --- a/rkhunter/map.jinja +++ b/rkhunter/map.jinja @@ -4,21 +4,41 @@ {#- Get the `tplroot` from `tpldir` #} {%- set tplroot = tpldir.split('/')[0] %} {#- Start imports as #} -{%- import_yaml tplroot ~ "/defaults.yaml" or {} as default_settings %} -{%- import_yaml tplroot ~ "/osfamilymap.yaml" or {} as osfamilymap %} -{%- import_yaml tplroot ~ "/osmap.yaml" or {} as osmap %} -{%- import_yaml tplroot ~ "/osfingermap.yaml" or {} as osfingermap %} +{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} +{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} +{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %} +{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %} -{%- set defaults = salt['grains.filter_by'](default_settings, - default='rkhunter', - 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['pillar.get']('rkhunter:lookup', default={}) +{#- Retrieve the config dict only once #} +{%- set _config = salt['config.get'](tplroot, default={}) %} + +{%- set defaults = salt['grains.filter_by']( + default_settings, + default=tplroot, + 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 + ) +%} -{#- Merge the rkhunter pillar #} -{%- set rkhunter = salt['pillar.get']('rkhunter', default=defaults, merge=True) %} +{%- set rkhunter = config %}