xoxys.mosquitto/tasks/config.yml

22 lines
649 B
YAML
Raw Normal View History

2017-12-18 09:52:02 +01:00
---
2018-11-05 20:15:12 +01:00
- name: Check if password file '{{ mosquitto_password_auth_file }}' exists
stat:
path: "{{ mosquitto_password_auth_file }}"
register: __mosquitto_passwd
become: True
become_user: root
2017-12-18 09:52:02 +01:00
2018-11-05 20:15:12 +01:00
- name: Create password file if not exist
file:
path: "{{ mosquitto_password_auth_file }}"
mode: 0600
state: touch
2018-11-05 00:31:54 +01:00
become: True
become_user: root
2018-11-05 20:15:12 +01:00
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 }}"
2018-11-05 20:28:54 +01:00
with_dict: "{{ mosquitto_password_auth_users | default('{}') }}"
2018-11-05 20:15:12 +01:00
notify: __mosquitto_restart