233 lines
6.7 KiB
YAML
233 lines
6.7 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.18
|
|
mosquitto_data: "{{ data_dir }}/mosquitto"
|
|
|
|
nodered_image: nodered/node-red:3.0.1-1-18
|
|
nodered_data: "{{ data_dir }}/nodered"
|
|
|
|
rabbitmq_image: bitnami/rabbitmq:3.13.4
|
|
rabbitmq_data: "{{ data_dir }}/rabbitmq"
|
|
|
|
pwr_meter_pulse_gw_image: netz39/power-meter-pulse-gateway:0.3.0
|
|
|
|
brotherql_host_port: 9004
|
|
|
|
roles:
|
|
# role 'docker_setup' applied through group 'docker_host'
|
|
- role: apache
|
|
- role: apache_letsencrypt # Uses configuration from dehydrated setup
|
|
- role: ansible-role-dehydrated
|
|
vars:
|
|
dehydrated_contact_email: "{{ server_admin }}"
|
|
dehydrated_domains:
|
|
- name: nodered.n39.eu
|
|
- name: rabbitmq.n39.eu
|
|
- name: pwr-meter-pulse-gw-19i.svc.n39.eu
|
|
- name: labelprinter.n39.eu
|
|
- role: ansible-role-dehydrated_cron
|
|
|
|
|
|
tasks:
|
|
- name: Ensure the mosquitto directories exist
|
|
file:
|
|
path: "{{ item }}"
|
|
mode: 0755
|
|
state: directory
|
|
with_items:
|
|
- "{{ mosquitto_data }}/config"
|
|
- "{{ mosquitto_data }}/data"
|
|
- "{{ mosquitto_data }}/log"
|
|
tags:
|
|
- mosquitto
|
|
|
|
- name: Make sure mosquitto config is there
|
|
template:
|
|
src: "templates/mosquitto.conf.j2"
|
|
dest: "{{ mosquitto_data }}/config/mosquitto.conf"
|
|
mode: 0644
|
|
notify: restart mosquitto
|
|
tags:
|
|
- 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
|
|
env:
|
|
TZ: "{{ timezone }}"
|
|
tags:
|
|
- mosquitto
|
|
|
|
- name: Check if nodered data dir exists
|
|
ansible.builtin.stat:
|
|
path: "{{ data_dir }}/nodered"
|
|
register: nodered_dir
|
|
- name: Fail if nodered data dir does not exist
|
|
ansible.builtin.fail:
|
|
msg: "Nodered data dir is missing, please restore from the backup!"
|
|
when: not nodered_dir.stat.exists
|
|
|
|
- name: Ensure nodered is running
|
|
docker_container:
|
|
name: nodered
|
|
image: "{{ nodered_image }}"
|
|
pull: true
|
|
state: started
|
|
env:
|
|
TZ: "{{ timezone }}"
|
|
NODE_RED_ENABLE_PROJECTS: "true"
|
|
ports:
|
|
- 127.0.0.1:9002:1880
|
|
volumes:
|
|
- "{{ nodered_data }}/data:/data"
|
|
# Mount the .ssh/known_hosts, otherwise the host must be confirmed
|
|
# (via docker exec) every time the container is updated.
|
|
- "{{ nodered_data }}/known_hosts:/usr/src/node-red/.ssh/known_hosts:rw"
|
|
detach: yes
|
|
keep_volumes: yes
|
|
restart_policy: unless-stopped
|
|
|
|
- name: Setup proxy site nodered.n39.eu
|
|
include_role:
|
|
name: setup_http_site_proxy
|
|
vars:
|
|
site_name: "nodered.n39.eu"
|
|
proxy_port: 9002
|
|
|
|
|
|
- name: Check if rabbitmq data dir exists
|
|
ansible.builtin.stat:
|
|
path: "{{ rabbitmq_data }}"
|
|
register: rabbitmq_dir
|
|
tags:
|
|
- rabbitmq
|
|
- name: Fail if rabbitmq data dir does not exist
|
|
ansible.builtin.fail:
|
|
msg: "RabbitMQ data dir is missing, please restore from the backup!"
|
|
when: not rabbitmq_dir.stat.exists
|
|
tags:
|
|
- rabbitmq
|
|
|
|
- name: Ensure rabbitmq docker container is running
|
|
docker_container:
|
|
name: rabbitmq
|
|
image: "{{ rabbitmq_image }}"
|
|
ports:
|
|
- 4369:4369
|
|
- 5551:5551
|
|
- 5552:5552
|
|
- 5672:5672
|
|
- 25672:25672
|
|
- 127.0.0.1:15672:15672
|
|
env:
|
|
TZ: "{{ timezone }}"
|
|
RABBITMQ_SECURE_PASSWORD: "yes"
|
|
volumes:
|
|
- "{{ rabbitmq_data }}/bitnami:/bitnami:rw"
|
|
- "{{ rabbitmq_data }}/etc_rabbitmq:/etc/rabbitmq:rw"
|
|
restart_policy: unless-stopped
|
|
tags:
|
|
- rabbitmq
|
|
|
|
- name: Setup proxy site rabbitmq.n39.eu
|
|
include_role:
|
|
name: setup_http_site_proxy
|
|
vars:
|
|
site_name: "rabbitmq.n39.eu"
|
|
proxy_port: 15672
|
|
tags:
|
|
- rabbitmq
|
|
|
|
- name: Ensure Power Meter Pulse Gateway for 19i room is running
|
|
docker_container:
|
|
name: pwr-meter-pulse-gw-19i
|
|
image: "{{ pwr_meter_pulse_gw_image }}"
|
|
ports:
|
|
# Wait for https://redmine.n39.eu/issues/755
|
|
# - 127.0.0.1:9003:8080
|
|
- 9003:8080
|
|
env:
|
|
TZ: "{{ timezone }}"
|
|
AMQP_HOST: "rabbitmq.n39.eu"
|
|
AMQP_USER: "{{ pwr_meter_amqp_user }}"
|
|
AMQP_PASS: "{{ pwr_meter_amqp_pass }}"
|
|
AMQP_VHOST: "/iot"
|
|
PULSE_BINDING: "pwr-meter-pulse-19i"
|
|
API_TOKEN: "{{ pwr_meter_api_token }}"
|
|
restart_policy: unless-stopped
|
|
|
|
- name: Setup proxy site pwr-meter-pulse-gw-19i.svc.n39.eu
|
|
include_role:
|
|
name: setup_http_site_proxy
|
|
vars:
|
|
site_name: "pwr-meter-pulse-gw-19i.svc.n39.eu"
|
|
proxy_port: 9003
|
|
|
|
|
|
- name: Setup docker container for BrotherQL Web UI printer
|
|
docker_container:
|
|
name: brotherql-web
|
|
image: dersimn/brother_ql_web:2.1.9-alpine
|
|
pull: true
|
|
restart_policy: unless-stopped
|
|
state: started
|
|
ports:
|
|
- "127.0.0.1:{{ brotherql_host_port }}:8013"
|
|
command: "--default-label-size 62 --model QL-720NW tcp://{{ brotherql_printer_host }}"
|
|
detach: yes
|
|
env:
|
|
TZ: "{{ timezone }}"
|
|
tags:
|
|
- labelprinter
|
|
|
|
- name: Setup proxy site labelprinter.n39.eu
|
|
include_role:
|
|
name: setup_http_site_proxy
|
|
vars:
|
|
site_name: labelprinter.n39.eu
|
|
proxy_port: "{{ brotherql_host_port }}"
|
|
tags:
|
|
- labelprinter
|
|
|
|
- name: Setup docker container for Grafana Screenshots
|
|
docker_container:
|
|
name: grafana-screenshot
|
|
image: mrtux/grafana-screenshot:0.1.1
|
|
pull: true
|
|
restart_policy: unless-stopped
|
|
detach: yes
|
|
env:
|
|
MQTT_BROKER_URL: "{{ kiosk_mqtt_host }}"
|
|
MQTT_TOPIC: "{{ kiosk_mqtt_topic }}"
|
|
GRAFANA_DASHBOARD_URL: "{{ kiosk_grafana_url }}"
|
|
GRAFANA_USERNAME: "{{ kiosk_grafana_user }}"
|
|
GRAFANA_PASSWORD: "{{ kiosk_grafana_pass }}"
|
|
tags:
|
|
- grafana-screenshot
|
|
|
|
handlers:
|
|
- name: restart mosquitto
|
|
docker_container:
|
|
name: mosquitto
|
|
state: started
|
|
restart: yes
|