From a17324b935e7433e9494b5fc5b8cf1366e21b061 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 27 Aug 2019 08:51:37 +0200 Subject: [PATCH] fix ansible_managed handling --- defaults/main.yml | 14 ++++++++------ templates/etc/mosquitto/aclfile.j2 | 13 ++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 72aa208..d0213ba 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -32,14 +32,16 @@ mosquitto_acl: [] # mosquitto_acl: # - name: iot # user: admin -# acl_base: topic # (topic|pattern, defaults to topic) -# acl_topic: "#" -# acl_policy: readwrite +# acls: +# - acl_base: topic # (topic|pattern, defaults to topic) +# acl_topic: "#" +# acl_policy: readwrite # - name: readonly_iot # user: user1 -# acl_base: topic -# acl_topic: my/devices -# acl_policy: readwrite +# acls: +# - acl_base: topic +# acl_topic: my/devices +# acl_policy: readwrite mosquitto_tls_enabled: False mosquitto_tls_ciphers: diff --git a/templates/etc/mosquitto/aclfile.j2 b/templates/etc/mosquitto/aclfile.j2 index 13b1877..0bf949b 100644 --- a/templates/etc/mosquitto/aclfile.j2 +++ b/templates/etc/mosquitto/aclfile.j2 @@ -1,11 +1,10 @@ -# {{ ansible_managed }} - -{% for key, value in mosquitto_acl.iteritems() %} -{% if not key == "all" %} -user {{ key }} +{{ ansible_managed | comment }} +{% for item in mosquitto_acl %} +{% if not item.name == "all" %} +user {{ item.name }} {% endif %} -{% for item in value %} -{{ item.acl_base if item.acl_base is defined else 'topic' }} {{ item.acl_policy }} {{ item.acl_topic }} +{% for acl in item.acls %} +{{ acl.acl_base if acl.acl_base is defined else 'topic' }} {{ acl.acl_policy }} {{ acl.acl_topic }} {% endfor %} {% endfor %}