xoxys.mosquitto/tasks/config.yml

51 lines
1.5 KiB
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
2018-11-05 20:39:18 +01:00
# TODO: ugly workaround, move this to a custom module
2018-11-07 20:44:06 +01:00
- block:
- name: Add users to password file
2019-10-18 10:06:29 +02:00
command: "mosquitto_passwd -b {{ mosquitto_password_auth_file }} {{ item.name }} {{ item.password }}"
2019-08-27 08:48:09 +02:00
loop: "{{ mosquitto_password_auth_users }}"
loop_control:
label: "{{ item.name }}"
2019-08-27 09:13:46 +02:00
when: item.state == "present"
2018-11-07 20:44:06 +01:00
changed_when: False
no_log: True
- name: Remove unnecessary users from password file
2019-10-18 10:06:29 +02:00
command: "mosquitto_passwd -D {{ mosquitto_password_auth_file }} {{ item.name }}"
2019-08-27 08:48:09 +02:00
loop: "{{ mosquitto_password_auth_users }}"
loop_control:
label: "{{ item.name }}"
2019-08-27 09:13:46 +02:00
when: item.state == "absent"
2018-11-07 20:44:06 +01:00
changed_when: False
no_log: True
2018-11-05 20:39:18 +01:00
2018-11-07 20:44:06 +01:00
- name: Create acl file at '{{ mosquitto_acl_file }}'
template:
2018-11-07 21:21:51 +01:00
src: "etc/mosquitto/aclfile.j2"
2018-11-07 20:44:06 +01:00
dest: "{{ mosquitto_acl_file }}"
owner: root
group: root
mode: 0600
when:
2019-06-10 16:00:07 +02:00
- mosquitto_acl_enabled | bool
2018-11-07 22:00:41 +01:00
- mosquitto_acl is defined
2018-11-07 22:11:13 +01:00
notify: __mosquitto_restart
2018-11-05 20:39:18 +01:00
become: True
become_user: root