Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map.jinja: use grains.filter_by instead of defaults.merge #254

Merged
merged 1 commit into from
Feb 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions apache/map.jinja
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
{# vi: set ft=jinja: #}

{% import_yaml "apache/defaults.yaml" as defaults %}
{% import_yaml "apache/defaults.yaml" as default_settings %}
{% import_yaml "apache/osfamilymap.yaml" as osfamilymap %}
{% import_yaml "apache/oscodenamemap.yaml" as oscodenamemap %}
{% import_yaml "apache/osfingermap.yaml" as osfingermap %}
{% import_yaml "apache/modsecurity.yaml" as modsec %}

{# merge the modsecurity #}
{% set modsecurity = salt['grains.filter_by'](modsec, grain='os_family') or{} %}
{% do salt['defaults.merge'](defaults['apache'], modsecurity) %}
{% set defaults = salt['grains.filter_by'](default_settings,
default='apache',
merge=salt['grains.filter_by'](modsec, grain='os_family',
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['grains.filter_by'](oscodenamemap, grain='oscodename',
merge=salt['grains.filter_by'](osfingermap, grain='osfinger',
merge=salt['pillar.get']('apache:lookup', default={})
)
)
)
)
) %}

{# merge the osfamilymap #}
{% set osfamily = salt['grains.filter_by'](osfamilymap, grain='os_family') or{} %}
{% do salt['defaults.merge'](defaults['apache'], osfamily) %}

{# merge the oscodenamemap #}
{% set oscode = salt['grains.filter_by'](oscodenamemap, grain='oscodename') or {} %}
{% do salt['defaults.merge'](defaults['apache'], oscode) %}

{# merge the osfingermap #}
{% set osfinger = salt['grains.filter_by'](osfingermap, grain='osfinger') or {} %}
{% do salt['defaults.merge'](defaults['apache'], osfinger) %}

{# merge the lookup #}
{% set lookup = salt['pillar.get']('apache:lookup', default={}, merge=True) %}
{% do salt['defaults.merge'](defaults['apache'], lookup) %}

{# merge all #}
{% set apache = salt['pillar.get']('apache', default=defaults['apache'], merge=True) %}
{## Merge the apache pillar ##}
{% set apache = salt['pillar.get']('apache', default=defaults, merge=True) %}