From 4b6015abfc1659db03d720d9bfa9666f76904dc7 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Fri, 1 Sep 2017 22:39:51 +0200 Subject: [PATCH] Use defaults/main.yml to avoid checking for empty lists everywhere This fixes one task that was failing when no primary zone was defined (the task copying zone files) --- defaults/main.yml | 4 ++++ templates/zones_config.j2 | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 7e99f8c..3237b9f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,5 +1,9 @@ --- +nsd_primary_zones: [] +nsd_secondary_zones: [] +nsd_tsig_keys: [] + # Default variables, suitable for nsd4 on Debian (jessie or above) nsd_version: 4 diff --git a/templates/zones_config.j2 b/templates/zones_config.j2 index a08241b..e0f5d00 100644 --- a/templates/zones_config.j2 +++ b/templates/zones_config.j2 @@ -5,7 +5,7 @@ # definitions for all zones (primary and secondary) and TSIG keys. ## TSIG keys ## -{% for key in nsd_tsig_keys|default([]) %} +{% for key in nsd_tsig_keys %} key: name: "{{ key.tsig_keyname }}" secret: "{{ key.tsig_secret }}" @@ -16,7 +16,7 @@ key: ## Primary zones ## -{% for zone in nsd_primary_zones|default([]) %} +{% for zone in nsd_primary_zones %} # Primary zone definition for {{ zone.zone_name }} zone: name: "{{ zone.zone_name }}" @@ -31,7 +31,7 @@ zone: ## Secondary zones ## -{% for zone in nsd_secondary_zones|default([]) %} +{% for zone in nsd_secondary_zones %} # Secondary zone definition for {{ zone.zone_name }} zone: name: "{{ zone.zone_name }}"