From 769433d20ac56fbec3386cb38f2254a1b9210775 Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Wed, 5 Dec 2018 10:16:43 +0100 Subject: [PATCH] break: change with_items to loop --- CHANGELOG.md | 1 + README.md | 2 +- meta/main.yml | 2 +- tasks/base.yml | 13 +++++++------ tasks/keys.yml | 20 ++++++++++++-------- tasks/zones.yml | 10 +++++----- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f15c13..3b7bb67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). Which is based on [Keep A Changelog](http://keepachangelog.com/) ## [Unreleased] +- break: change with_items to loop ## v1.2.2 (2018-09-07) - fix: remove a bug in dnssec cron diff --git a/README.md b/README.md index 1d3750c..1390d91 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Install and configure bind with dnssec ## Requirements -* Ansible >= 2.4 +* Ansible >= 2.6 * bind version >= 9.8 * Debian Stretch diff --git a/meta/main.yml b/meta/main.yml index e371734..df49cb2 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -2,7 +2,7 @@ galaxy_info: author: Adrien Waksberg description: Install and configure bind9 with dnssec license: Apache2 - min_ansible_version: 2.4 + min_ansible_version: 2.6 platforms: - name: Debian diff --git a/tasks/base.yml b/tasks/base.yml index dc67de4..aef5d36 100644 --- a/tasks/base.yml +++ b/tasks/base.yml @@ -1,11 +1,12 @@ - name: install packages for bind9 apt: - name: '{{ item }}' + name: '{{ packages }}' state: present - with_items: - - bind9 - - bind9-host - - cron + vars: + packages: + - bind9 + - bind9-host + - cron - name: create zone directory file: @@ -30,7 +31,7 @@ owner: root group: root mode: 0644 - with_items: + loop: - named.conf - named.conf.options - named.conf.local diff --git a/tasks/keys.yml b/tasks/keys.yml index ea1ab84..4e8e659 100644 --- a/tasks/keys.yml +++ b/tasks/keys.yml @@ -5,10 +5,12 @@ owner: root group: bind mode: 0640 -# no_log: true - with_nested: - - '{{ bind_dnssec }}' - - [ 'ksk', 'zsk' ] + no_log: true + loop: '{{ bind_dnssec|product(file_ext)|list }}' + vars: + file_ext: + - ksk + - zsk - name: copy public key template: @@ -17,7 +19,9 @@ owner: root group: bind mode: 0640 -# no_log: true - with_nested: - - '{{ bind_dnssec }}' - - [ 'ksk', 'zsk' ] + no_log: true + loop: '{{ bind_dnssec|product(file_ext)|list }}' + vars: + file_ext: + - ksk + - zsk diff --git a/tasks/zones.yml b/tasks/zones.yml index 989ffe2..e700998 100644 --- a/tasks/zones.yml +++ b/tasks/zones.yml @@ -1,6 +1,6 @@ - set_fact: bind_zones_play: '{{ bind_zones_play|default([]) + [ item ] }}' - with_dict: '{{ bind_zones }}' + loop: '{{ bind_zones|dict2items }}' when: (item.value.state is not defined or item.value.state != 'absent') and (bind_zones_subset is not defined or item.key in bind_zones_subset) - name: create zone folder @@ -10,7 +10,7 @@ group: bind mode: 0755 state: directory - with_items: '{{ bind_zones_play }}' + loop: '{{ bind_zones_play }}' - name: copy zone files template: @@ -19,7 +19,7 @@ owner: root group: root mode: 0644 - with_items: '{{ bind_zones_play }}' + loop: '{{ bind_zones_play }}' register: zone notify: reload bind @@ -27,7 +27,7 @@ shell: 'dnssec-signzone -3 $(head -n 1000 /dev/urandom | sha1sum | cut -b 1-16) -A -N INCREMENT -o {{ item.item.key }} -t /etc/bind/zones/{{ item.item.key }}/db' args: chdir: /etc/bind/keys - with_items: '{{ zone.results }}' + loop: '{{ zone.results }}' when: item.changed and item.item.key in bind_dnssec notify: reload bind @@ -42,5 +42,5 @@ file: path: '{{ item.path }}' state: absent - with_items: '{{ zone_folders.files }}' + loop: '{{ zone_folders.files }}' when: item.path|basename not in bind_zones or ('state' in bind_zones[item.path|basename] and bind_zones[item.path|basename].state == 'absent')