netz39-infra-ansible/pottwal.yml

145 lines
3.8 KiB
YAML
Raw Normal View History

2020-12-10 22:15:09 +01:00
- hosts: pottwal.n39.eu
become: true
vars:
ansible_python_interpreter: /usr/bin/python3
2020-12-12 17:19:14 +01:00
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
openhab_configuration_source: https://github.com/netz39/n39-openhab.git
openhab_configuration_version: master
uritools_host_port: 8080
2020-12-10 22:15:09 +01:00
roles:
2020-12-12 14:09:05 +01:00
- role: docker_setup
vars:
docker_data_root: "/srv/docker"
2020-12-10 22:15:09 +01:00
- role: apache
tasks:
2020-12-12 17:03:46 +01:00
- name: Ensure apt-cacher container is running
docker_container:
name: apt_cacher_ng
image: "mrtux/apt-cacher-ng"
pull: true
state: started
restart_policy: unless-stopped
detach: yes
ports:
- 3142:3142
2020-12-12 17:19:14 +01:00
- 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
2020-12-12 17:19:14 +01:00
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 }}"
state: directory
with_items:
- "{{ openhab_data }}/addons"
- "{{ openhab_data }}/conf"
- "{{ openhab_data }}/userdata"
- name: Clone or update configuration
git:
repo: "{{ openhab_configuration_source }}"
version: "{{ openhab_configuration_version }}"
dest: "{{ openhab_data }}/conf"
clone: yes
update: yes
notify: restart openhab
- name: ensure openhab is up and running
docker_container:
name: openhab
image: "{{ openhab_image }}"
pull: true
state: started
detach: yes
interactive: yes
tty: yes
ports:
- "{{ openhab_host_port }}:8080"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- "{{ openhab_data }}/addons:/openhab/addons:rw"
- "{{ openhab_data }}/conf:/openhab/conf:rw"
- "{{ openhab_data }}/userdata:/openhab/userdata:rw"
keep_volumes: yes
restart_policy: unless-stopped
env:
EXTRA_JAVA_OPTS="-Duser.timezone=Europe/Berlin"
- name: Setup proxy site openhab.n39.eu
include_role:
name: setup-http-site-proxy
vars:
site_name: openhab.n39.eu
proxy_port: "{{ openhab_host_port }}"
- name: Ensure container for URI tools is running
docker_container:
name: uritools
image: mrtux/clean_uri
pull: true
state: started
detach: yes
ports:
- "{{ uritools_host_port }}:8080"
restart_policy: unless-stopped
- name: Setup proxy site uritools.n39.eu
include_role:
name: setup-http-site-proxy
vars:
site_name: uritools.n39.eu
proxy_port: "{{ uritools_host_port }}"
handlers:
- name: restart openhab
docker_container:
name: openhab
state: started
restart: yes
2020-12-12 17:19:14 +01:00
- name: restart mosquitto
docker_container:
name: mosquitto
state: started
restart: yes