xoxys.mosquitto/tasks/config.yml

22 lines
641 B
YAML

---
- name: Check if password file '{{ mosquitto_password_auth_file }}' exists
stat:
path: "{{ mosquitto_password_auth_file }}"
register: __mosquitto_passwd
become: True
become_user: root
- name: Create password file if not exist
file:
path: "{{ mosquitto_password_auth_file }}"
mode: 0600
state: touch
become: True
become_user: root
when: not __mosquitto_passwd.stat.exists
- name: Add users to password file
shell: "mosquitto_passwd -b {{ mosquitto_password_auth_file }} {{ item.name }} {{ item.value.password }}"
with_dict: "{{ mosquitto_login_users | default(omit) }}"
notify: __mosquitto_restart