From cf632d1a569b5e43388de11e112a61942899c45f Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Tue, 7 Apr 2020 13:23:37 +0200 Subject: [PATCH] mqtt: Ensure create auth files before writing using mosquitto_passwd Fixes error on calling tool if file does not exist --- roles/mqtt/application/tasks/main.yml | 8 ++++++++ roles/mqtt/user/tasks/main.yml | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/roles/mqtt/application/tasks/main.yml b/roles/mqtt/application/tasks/main.yml index 153be38..5cac272 100644 --- a/roles/mqtt/application/tasks/main.yml +++ b/roles/mqtt/application/tasks/main.yml @@ -40,6 +40,14 @@ mode: "u=rw,g=r,o=r" notify: reconfigure mosquitto acl +- name: Create auth main file + file: + state: touch + path: "{{ environment_directory | quote }}/0_main.auth" + owner: root + group: root + mode: "u=rw,g=r,o=r" + - name: Store auth main file command: >- mosquitto_passwd diff --git a/roles/mqtt/user/tasks/main.yml b/roles/mqtt/user/tasks/main.yml index 6d5c255..573877b 100644 --- a/roles/mqtt/user/tasks/main.yml +++ b/roles/mqtt/user/tasks/main.yml @@ -9,6 +9,14 @@ mode: "u=rw,g=r,o=r" notify: reconfigure mosquitto acl +- name: Create auth file for user + file: + state: touch + path: "{{ environment_directory | quote }}/{{ user | quote }}.auth" + owner: root + group: root + mode: "u=rw,g=r,o=r" + - name: Store auth file for user command: >- mosquitto_passwd