netz39-infra-ansible/radon.yml
Stefan Haun 81a261deb0 Introduce a data_dir variable for radon
We've had too many confusions about the actual data directory and
unfortunately there are also inconsistencies. So use the data_dir
variable to mask host specific settings.
2022-06-29 00:15:56 +02:00

56 lines
1.4 KiB
YAML

---
- hosts: radon.n39.eu
become: true
vars:
ansible_python_interpreter: /usr/bin/python3
data_dir: "/srv/data"
mosquitto_image: eclipse-mosquitto:2.0.14
mosquitto_data: "{{ data_dir }}/mosquitto"
roles:
- role: docker_setup
vars:
docker_data_root: "/srv/docker"
tasks:
- 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
- 9001:9001
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
handlers:
- name: restart mosquitto
docker_container:
name: mosquitto
state: started
restart: yes