From 5de7a25bfae3f80e6cb8e03339e7412cbe198088 Mon Sep 17 00:00:00 2001 From: Stefan Haun Date: Sat, 12 Dec 2020 17:19:14 +0100 Subject: [PATCH] Setup mosquitto container on pottwal --- pottwal.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/pottwal.yml b/pottwal.yml index 066f494..9ddcb39 100644 --- a/pottwal.yml +++ b/pottwal.yml @@ -4,6 +4,9 @@ vars: ansible_python_interpreter: /usr/bin/python3 + mosquitto_image: eclipse-mosquitto:1.6 + mosquitto_data: /srv/data/mosquitto + openhab_image: openhab/openhab:2.5.10 openhab_data: /srv/data/openhab openhab_host_port: 8081 @@ -28,6 +31,37 @@ ports: - 3142:3142 + - name: Ensure the mosquitto directories exist + file: + path: "{{ item }}" + state: directory + with_items: + - "{{ mosquitto_data }}/config" + - "{{ mosquitto_data }}/data" + - "{{ mosquitto_data }}/log" + + - name: Make sure mosquitto config is there + template: + src: "templates/mosquitto.conf.j2" + dest: "{{ mosquitto_data }}/config/mosquitto.conf" + notify: restart_mosquitto + + - name: Ensure mosquitto is running + docker_container: + name: mosquitto + image: "{{ mosquitto_image }}" + pull: true + state: started + ports: + - 1883:1883 + volumes: + - "{{ mosquitto_data }}/config:/mosquitto/config" + - "{{ mosquitto_data }}/data:/mosquitto/data" + - "{{ mosquitto_data }}/log:/mosquitto/log" + detach: yes + keep_volumes: yes + restart_policy: unless-stopped + - name: Ensure the openhab directories exist file: path: "{{ item }}" @@ -81,3 +115,9 @@ name: openhab state: started restart: yes + + - name: restart mosquitto + docker_container: + name: mosquitto + state: started + restart: yes