2022-06-24 17:01:50 +02:00
|
|
|
---
|
|
|
|
- hosts: radon.n39.eu
|
|
|
|
become: true
|
|
|
|
|
|
|
|
vars:
|
|
|
|
ansible_python_interpreter: /usr/bin/python3
|
|
|
|
|
2022-06-29 00:15:56 +02:00
|
|
|
data_dir: "/srv/data"
|
|
|
|
|
2022-06-25 18:27:53 +02:00
|
|
|
mosquitto_image: eclipse-mosquitto:2.0.14
|
2022-06-29 00:15:56 +02:00
|
|
|
mosquitto_data: "{{ data_dir }}/mosquitto"
|
2022-06-25 18:15:52 +02:00
|
|
|
|
2022-07-29 15:17:51 +02:00
|
|
|
nodered_image: nodered/node-red:3.0.1-1-18
|
|
|
|
nodered_data: "{{ data_dir }}/nodered"
|
|
|
|
|
2022-08-24 20:48:46 +02:00
|
|
|
rabbitmq_image: "bitnami/rabbitmq:3.10.7"
|
|
|
|
rabbitmq_data: "{{ data_dir }}/rabbitmq"
|
|
|
|
|
2022-09-09 15:00:23 +02:00
|
|
|
pwr_meter_pulse_gw_image: "netz39/power-meter-pulse-gateway:0.3.0"
|
2022-08-27 13:30:30 +02:00
|
|
|
|
2022-09-06 20:53:54 +02:00
|
|
|
brotherql_host_port: 9004
|
|
|
|
brotherql_web_image: "pklaus/brother_ql_web:alpine_9e20b6d"
|
|
|
|
|
2022-06-24 17:01:50 +02:00
|
|
|
roles:
|
2022-12-12 18:53:03 +01:00
|
|
|
# role 'docker_setup' applied through group 'docker_host'
|
2022-08-27 16:44:18 +02:00
|
|
|
- role: apache
|
2022-10-23 22:49:57 +02:00
|
|
|
- role: apache_letsencrypt # Uses configuration from dehydrated setup
|
2022-08-27 16:44:27 +02:00
|
|
|
- role: ansible-role-dehydrated
|
|
|
|
vars:
|
|
|
|
dehydrated_contact_email: "{{ server_admin }}"
|
|
|
|
dehydrated_domains:
|
2022-10-26 18:56:20 +02:00
|
|
|
- name: nodered.n39.eu
|
|
|
|
- name: rabbitmq.n39.eu
|
|
|
|
- name: pwr-meter-pulse-gw-19i.svc.n39.eu
|
2023-06-17 11:53:55 +02:00
|
|
|
- name: labelprinter.n39.eu
|
2022-08-27 20:41:15 +02:00
|
|
|
- role: penguineer.dehydrated_cron
|
2022-08-27 16:44:27 +02:00
|
|
|
|
2022-06-24 17:01:50 +02:00
|
|
|
|
|
|
|
tasks:
|
2022-06-25 18:15:52 +02:00
|
|
|
- name: Ensure the mosquitto directories exist
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
2022-10-26 21:58:52 +02:00
|
|
|
mode: 0755
|
2022-06-25 18:15:52 +02:00
|
|
|
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"
|
2022-10-26 21:59:37 +02:00
|
|
|
mode: 0644
|
2022-06-25 18:23:04 +02:00
|
|
|
notify: restart mosquitto
|
2022-06-25 18:15:52 +02:00
|
|
|
|
|
|
|
- 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
|
2022-11-07 16:43:12 +01:00
|
|
|
env:
|
|
|
|
TZ: "{{ timezone }}"
|
2022-06-24 17:01:50 +02:00
|
|
|
|
2022-07-29 15:17:51 +02:00
|
|
|
- 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:
|
2022-11-07 16:43:12 +01:00
|
|
|
TZ: "{{ timezone }}"
|
2022-07-29 15:17:51 +02:00
|
|
|
NODE_RED_ENABLE_PROJECTS: "true"
|
|
|
|
ports:
|
2022-08-27 16:52:52 +02:00
|
|
|
- 127.0.0.1:9002:1880
|
2022-07-29 15:17:51 +02:00
|
|
|
volumes:
|
|
|
|
- "{{ nodered_data }}/data:/data"
|
2022-09-06 20:01:23 +02:00
|
|
|
# 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"
|
2022-07-29 15:17:51 +02:00
|
|
|
detach: yes
|
|
|
|
keep_volumes: yes
|
|
|
|
restart_policy: unless-stopped
|
|
|
|
|
2022-08-27 16:52:52 +02:00
|
|
|
- name: Setup proxy site nodered.n39.eu
|
|
|
|
include_role:
|
2022-10-23 22:55:09 +02:00
|
|
|
name: setup_http_site_proxy
|
2022-08-27 16:52:52 +02:00
|
|
|
vars:
|
|
|
|
site_name: "nodered.n39.eu"
|
|
|
|
proxy_port: 9002
|
|
|
|
|
2022-07-29 15:17:51 +02:00
|
|
|
|
2022-08-24 20:48:46 +02:00
|
|
|
- name: Check if rabbitmq data dir exists
|
|
|
|
ansible.builtin.stat:
|
|
|
|
path: "{{ rabbitmq_data }}"
|
|
|
|
register: rabbitmq_dir
|
|
|
|
- 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
|
|
|
|
|
|
|
|
- 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
|
2022-08-27 20:36:20 +02:00
|
|
|
- 127.0.0.1:15672:15672
|
2022-08-24 20:48:46 +02:00
|
|
|
env:
|
2022-11-07 16:43:12 +01:00
|
|
|
TZ: "{{ timezone }}"
|
2022-08-24 20:48:46 +02:00
|
|
|
RABBITMQ_SECURE_PASSWORD: "yes"
|
|
|
|
volumes:
|
|
|
|
- "{{ rabbitmq_data }}/bitnami:/bitnami:rw"
|
|
|
|
- "{{ rabbitmq_data }}/etc_rabbitmq:/etc/rabbitmq:rw"
|
2022-09-30 21:52:01 +02:00
|
|
|
restart_policy: unless-stopped
|
2022-08-24 20:48:46 +02:00
|
|
|
|
2022-08-27 20:36:20 +02:00
|
|
|
- name: Setup proxy site rabbitmq.n39.eu
|
|
|
|
include_role:
|
2022-10-23 22:55:09 +02:00
|
|
|
name: setup_http_site_proxy
|
2022-08-27 20:36:20 +02:00
|
|
|
vars:
|
|
|
|
site_name: "rabbitmq.n39.eu"
|
|
|
|
proxy_port: 15672
|
|
|
|
|
|
|
|
|
2022-08-27 13:30:30 +02:00
|
|
|
- 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:
|
2022-08-27 20:38:08 +02:00
|
|
|
# Wait for https://redmine.n39.eu/issues/755
|
2022-08-27 13:30:30 +02:00
|
|
|
# - 127.0.0.1:9003:8080
|
|
|
|
- 9003:8080
|
|
|
|
env:
|
2022-11-07 16:43:12 +01:00
|
|
|
TZ: "{{ timezone }}"
|
2022-08-27 13:30:30 +02:00
|
|
|
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 }}"
|
2022-09-30 21:52:01 +02:00
|
|
|
restart_policy: unless-stopped
|
2022-08-27 13:30:30 +02:00
|
|
|
|
2022-08-27 20:38:08 +02:00
|
|
|
- name: Setup proxy site pwr-meter-pulse-gw-19i.svc.n39.eu
|
|
|
|
include_role:
|
2022-10-23 22:55:09 +02:00
|
|
|
name: setup_http_site_proxy
|
2022-08-27 20:38:08 +02:00
|
|
|
vars:
|
|
|
|
site_name: "pwr-meter-pulse-gw-19i.svc.n39.eu"
|
|
|
|
proxy_port: 9003
|
2022-08-27 13:30:30 +02:00
|
|
|
|
|
|
|
|
2022-09-06 20:53:54 +02:00
|
|
|
- name: Setup docker container for BrotherQL Web UI printer
|
|
|
|
docker_container:
|
|
|
|
name: brotherql-web
|
|
|
|
image: "{{ brotherql_web_image }}"
|
|
|
|
pull: true
|
|
|
|
restart_policy: unless-stopped
|
|
|
|
state: started
|
|
|
|
ports:
|
|
|
|
- "127.0.0.1:{{ brotherql_host_port }}:8013"
|
|
|
|
command: " ./brother_ql_web.py --model QL-720NW tcp://{{ brotherql_printer_ip }}"
|
|
|
|
detach: yes
|
2022-11-07 16:43:12 +01:00
|
|
|
env:
|
|
|
|
TZ: "{{ timezone }}"
|
2022-09-06 20:53:54 +02:00
|
|
|
|
2023-06-17 11:53:55 +02:00
|
|
|
- name: Setup proxy site labelprinter.n39.eu
|
2022-09-06 20:53:54 +02:00
|
|
|
include_role:
|
2022-10-25 16:35:42 +02:00
|
|
|
name: setup_http_site_proxy
|
2022-09-06 20:53:54 +02:00
|
|
|
vars:
|
2023-06-17 11:53:55 +02:00
|
|
|
site_name: labelprinter.n39.eu
|
2022-09-06 20:53:54 +02:00
|
|
|
proxy_port: "{{ brotherql_host_port }}"
|
|
|
|
|
|
|
|
|
2022-06-24 17:01:50 +02:00
|
|
|
handlers:
|
2022-06-25 18:15:52 +02:00
|
|
|
- name: restart mosquitto
|
|
|
|
docker_container:
|
|
|
|
name: mosquitto
|
|
|
|
state: started
|
|
|
|
restart: yes
|