diff --git a/files/mosquitto/mosquitto.conf b/files/mosquitto/mosquitto.conf index ce7c5910..4a21b2b1 100644 --- a/files/mosquitto/mosquitto.conf +++ b/files/mosquitto/mosquitto.conf @@ -1,4 +1,3 @@ persistence true persistence_location /mosquitto/data/ log_dest file /mosquitto/log/mosquitto.log - diff --git a/group_vars/all.yml b/group_vars/all.yml index 426a2fdd..2a191dca 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -290,14 +290,6 @@ wallabag_available_externally: "false" wallabag_data_directory: "{{ docker_home }}/wallabag" wallabag_port: "7780" -### -### Mosquitto -### -mosquitto_available_externally: "false" -mosquitto_data_directory: "{{ docker_home }}/mosquitto" -mosquitto_port_a: "1883" -mosquitto_port_b: "9001" - ### ### Calibre-web ### diff --git a/nas.yml b/nas.yml index 070fa018..113c4698 100644 --- a/nas.yml +++ b/nas.yml @@ -178,6 +178,11 @@ - miniflux when: (miniflux_enabled | default(False)) + - role: mosquitto + tags: + - mosquitto + when: (mosquitto_enabled | default(False)) + - role: mylar tags: - mylar @@ -359,10 +364,6 @@ when: (wallabag_enabled | default(False)) tags: wallabag - - import_tasks: tasks/mosquitto.yml - when: (mosquitto_enabled | default(False)) - tags: mosquitto - - import_tasks: tasks/calibre.yml when: (calibre_enabled | default(False)) tags: calibre diff --git a/roles/mosquitto/defaults/main.yml b/roles/mosquitto/defaults/main.yml new file mode 100644 index 00000000..f1aa88a6 --- /dev/null +++ b/roles/mosquitto/defaults/main.yml @@ -0,0 +1,16 @@ +--- +mosquitto_enabled: false + +# directories +mosquitto_data_directory: "{{ docker_home }}/mosquitto" + +# uid / gid +mosquitto_user_id: "0" +mosquitto_group_id: "0" + +# network +mosquitto_port_a: "1883" +mosquitto_port_b: "9001" + +# specs +mosquitto_memory: 1g diff --git a/roles/mosquitto/files/mosquitto.conf b/roles/mosquitto/files/mosquitto.conf new file mode 100644 index 00000000..f4a6ab2e --- /dev/null +++ b/roles/mosquitto/files/mosquitto.conf @@ -0,0 +1,7 @@ +persistence true +persistence_location /mosquitto/data/ +log_dest file /mosquitto/log/mosquitto.log +log_dest stdout +listener 1883 0.0.0.0 +allow_anonymous true + diff --git a/tasks/mosquitto.yml b/roles/mosquitto/tasks/main.yml similarity index 89% rename from tasks/mosquitto.yml rename to roles/mosquitto/tasks/main.yml index 93f8ff4a..aa787c77 100644 --- a/tasks/mosquitto.yml +++ b/roles/mosquitto/tasks/main.yml @@ -3,7 +3,6 @@ file: path: "{{ item }}" state: directory - mode: 0777 with_items: - "{{ mosquitto_data_directory }}/config" - "{{ mosquitto_data_directory }}/data" @@ -11,8 +10,9 @@ - name: Template mosquitto.conf copy: - src: mosquitto/mosquitto.conf + src: mosquitto.conf dest: "{{ mosquitto_data_directory }}/config/mosquitto.conf" + register: mosquitto_conf - name: Create Mosquitto container docker_container: @@ -27,4 +27,5 @@ - "{{ mosquitto_port_a }}:1883" - "{{ mosquitto_port_b }}:9001" restart_policy: unless-stopped + restart: "{{ mosquitto_conf is changed }}" memory: 1g