fix user hadling

This commit is contained in:
Robert Kaussow 2018-11-05 20:39:18 +01:00
parent da82193ac9
commit 76fb609d0d
2 changed files with 17 additions and 3 deletions

View File

@ -17,8 +17,10 @@ mosquitto_password_auth_file: "{{ mosquitto_base_dir }}/passwd"
# mosquitto_password_auth_users: (defaults to not set) # mosquitto_password_auth_users: (defaults to not set)
# - admin: # - admin:
# password: mysecret # password: mysecret
# state: present
# - user1: # - user1:
# password: very_secure # password: very_secure
# state: absent
mosquitto_acl_enabled: False mosquitto_acl_enabled: False
mosquitto_acl_file: "{{ mosquitto_base_dir }}/aclfile" mosquitto_acl_file: "{{ mosquitto_base_dir }}/aclfile"

View File

@ -15,7 +15,19 @@
become_user: root become_user: root
when: not __mosquitto_passwd.stat.exists when: not __mosquitto_passwd.stat.exists
# TODO: ugly workaround, move this to a custom module
- name: Add users to password file - name: Add users to password file
shell: "mosquitto_passwd -b {{ mosquitto_password_auth_file }} {{ item.name }} {{ item.value.password }}" shell: "mosquitto_passwd -b {{ mosquitto_password_auth_file }} {{ item.key }} {{ item.value.password }}"
with_dict: "{{ mosquitto_password_auth_users | default('{}') }}" with_dict: "{{ mosquitto_password_auth_users | default('{}') }}"
notify: __mosquitto_restart notify: __mosquitto_restart
become: True
become_user: root
when: item.value.state == "present"
- name: Remove unnecessary users from password file
shell: "mosquitto_passwd -b {{ mosquitto_password_auth_file }} {{ item.key }}"
with_dict: "{{ mosquitto_password_auth_users | default('{}') }}"
notify: __mosquitto_restart
become: True
become_user: root
when: item.value.state == "absent"