Work around a jinja2 bug in the map filter regarding default values (https://github.com/pallets/jinja/issues/1331)

This commit is contained in:
s3lph 2021-02-05 22:28:20 +01:00
parent 3200fe522a
commit 47bf844bf1

View file

@ -24,16 +24,18 @@ log:
#
key:
{% for remote in ( (zones | map(attribute='replicas') ) + (zones | map(attribute='masters') ) + (zones | map(attribute='updaters', default=[]) ) ) | flatten | unique %}
{% for remote in ( (zones | map(attribute='replicas') ) + (zones | map(attribute='masters') ) + (zones | map(attribute='updaters') | select('defined') ) ) | flatten | unique %}
{% if 'knot_tsig_key' in hostvars[remote] %}
- id: {{ hostvars[remote].knot_tsig_key.name }}
algorithm: {{ hostvars[remote].knot_tsig_key.algorithm }}
secret: {{ hostvars[remote].knot_tsig_key.secret }}
{% endif %}
{% endfor %}
remote:
{% for remote in ( (zones | map(attribute='replicas') ) + (zones | map(attribute='masters') ) + (zones | map(attribute='updaters', default=[]) ) ) | flatten | unique %}
{% for remote in ( (zones | map(attribute='replicas') ) + (zones | map(attribute='masters') ) + (zones | map(attribute='updaters') | select('defined') ) ) | flatten | unique %}
- id: remote-{{ remote }}
{% for address in hostvars[remote].knot_dns_addresses %}
@ -46,7 +48,7 @@ acl:
- id: acl-xfr-{{ remote }}
action: transfer
{% if knot_tsig_key in hostvars[remote] %}
{% if 'knot_tsig_key' in hostvars[remote] %}
key: {{ hostvars[remote].knot_tsig_key.name }}
{% else %}
{% for address in hostvars[remote].knot_dns_addresses %}
@ -59,7 +61,7 @@ acl:
- id: acl-notify-{{ remote }}
action: notify
{% if knot_tsig_key in hostvars[remote] %}
{% if 'knot_tsig_key' in hostvars[remote] %}
key: {{ hostvars[remote].knot_tsig_key.name }}
{% else %}
{% for address in hostvars[remote].knot_dns_addresses %}
@ -68,7 +70,7 @@ acl:
{% endif %}
{% endfor %}
{% for remote in zones | map(attribute='updaters', default=[]) | flatten | unique %}
{% for remote in zones | map(attribute='updaters') | select('defined') | flatten | unique %}
- id: acl-update-{{ remote }}
action: update