r/mosquitto: Support persistence

Mosquitto can save retained messages, persistent clients, etc. to the
filesystem and restore them at startup.  This allows state to be
maintained even after the process restarts.
This commit is contained in:
2022-05-29 11:25:25 -05:00
parent 24228953b0
commit e7534d36cf
2 changed files with 41 additions and 0 deletions

View File

@@ -5,6 +5,17 @@
tags:
- install
- name: ensure mosquitto persistence directory exists
file:
path: '{{ mosquitto_persistence_location }}'
mode: u=rwx,go=
owner: mosquitto
group: mosquitto
state: directory
when: mosquitto_persistence_location|d(none) is not none
tags:
- datadir
- name: ensure mosquitto certificate is installed
copy:
src: certs/mosquitto/{{ inventory_hostname }}.cer
@@ -15,6 +26,8 @@
notify:
- restart mosquitto
when: mosquitto_certfile is defined
tags:
- cert
- name: ensure mosquitto private key is installed
copy:
src: certs/mosquitto/{{ inventory_hostname }}.key
@@ -26,6 +39,8 @@
notify:
- restart mosquitto
when: mosquitto_keyfile is defined
tags:
- cert
- name: ensure mosquitto is configured
template:
@@ -34,6 +49,8 @@
mode: '0644'
notify:
- restart mosquitto
tags:
- mosquitto-config
- meta: flush_handlers
@@ -41,7 +58,11 @@
service:
name: mosquitto
enabled: true
tags:
- service
- name: ensure mosquitto is running
service:
name: mosquitto
state: started
tags:
- service