firewalld-formula/firewalld/map.jinja
Steven Daniele 94d2b0b97c
fix: do not error on unknown os_family grain
If the formula was ran on a system that reported an os_family that
wasn't one of "Debian", "RedHat", "Arch", "Suse" then the map.jinja
template would fail to render with "'NoneType' is not iterable.

This occurs because grains.filter_by will return None when it fails
match the grain to the input dictionary. The value is then blindly
passed into a dict.update() which causes the failure.

In this patch we ensure that the default values, as defined in
defaults.yaml, are always applied when grain matching fails.
2020-04-18 15:53:46 +01:00

21 lines
589 B
Django/Jinja

# -*- coding: utf-8 -*-
# vim: ft=jinja
{#- Start with defaults from defaults.yaml #}
{% import_yaml "firewalld/defaults.yaml" as default_settings %}
{% import_yaml "firewalld/osfamilymap.yaml" as osfamilymap %}
{% set platform_defaults = salt['grains.filter_by'](default_settings,
default='default',
merge=salt['grains.filter_by'](osfamilymap, grain='os_family',
merge=salt['pillar.get']('firewalld:lookup')
)
) %}
{#- Merge in salt:lookup pillar #}
{% set firewalld = salt['pillar.get'](
'firewalld',
default=platform_defaults.firewalld,
merge=True)
%}