2019-02-03 00:32:17 +00:00
|
|
|
- name: "Install packages: mosquitto, mosquitto-clients"
|
2018-06-27 19:43:33 +00:00
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2018-06-27 08:52:11 +00:00
|
|
|
with_items:
|
|
|
|
- mosquitto
|
|
|
|
- mosquitto-clients
|
|
|
|
when: mosquitto_install
|
|
|
|
tags: download
|
|
|
|
|
2019-02-03 00:32:17 +00:00
|
|
|
- name: Disable & Stop 'mosquitto' service
|
2019-01-15 18:18:09 +00:00
|
|
|
systemd:
|
2018-06-27 08:52:11 +00:00
|
|
|
name: mosquitto
|
|
|
|
enabled: no
|
|
|
|
state: stopped
|
2019-01-15 16:32:59 +00:00
|
|
|
when: mosquitto_install
|
2018-06-27 08:52:11 +00:00
|
|
|
|
2019-01-15 18:18:09 +00:00
|
|
|
- name: Create (touch) file /etc/mosquitto/passwd
|
2018-06-27 08:52:11 +00:00
|
|
|
file:
|
|
|
|
path: /etc/mosquitto/passwd
|
|
|
|
state: touch
|
2019-01-15 18:18:09 +00:00
|
|
|
mode: "u=rw,g=r,o=r" # 0644
|
2019-01-15 16:32:59 +00:00
|
|
|
when: mosquitto_install
|
2018-06-27 08:52:11 +00:00
|
|
|
|
2019-01-15 18:18:09 +00:00
|
|
|
- name: Populate /etc/mosquitto/passwd with actual username/password
|
2018-06-27 08:52:11 +00:00
|
|
|
shell: mosquitto_passwd -b /etc/mosquitto/passwd "{{ mosquitto_user }}" "{{ mosquitto_password }}"
|
2019-01-15 16:32:59 +00:00
|
|
|
when: mosquitto_install
|
2018-06-27 08:52:11 +00:00
|
|
|
|
2019-01-15 18:18:09 +00:00
|
|
|
- name: Install /etc/mosquitto/conf.d/websockets.conf from template
|
2018-06-27 08:52:11 +00:00
|
|
|
template:
|
|
|
|
backup: yes
|
2019-01-15 18:18:09 +00:00
|
|
|
src: websockets.conf.j2
|
|
|
|
dest: /etc/mosquitto/conf.d/websockets.conf
|
2018-06-27 08:52:11 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
2019-01-15 18:18:09 +00:00
|
|
|
mode: 0755
|
2019-01-15 16:32:59 +00:00
|
|
|
when: mosquitto_install
|
2018-06-27 08:52:11 +00:00
|
|
|
|
2019-02-03 00:32:17 +00:00
|
|
|
- name: Enable & Start 'mosquitto' service
|
2019-01-15 18:18:09 +00:00
|
|
|
systemd:
|
2019-01-16 06:22:35 +00:00
|
|
|
daemon_reload: yes
|
2018-06-27 08:52:11 +00:00
|
|
|
name: mosquitto
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
when: mosquitto_enabled
|