ansible-nas/tasks/openhab.yml
2021-01-19 23:51:59 +00:00

53 lines
1.6 KiB
YAML

---
- name: Create openHAB group
group:
name: openhab
gid: 9001
state: present
- name: Create openHAB user
user:
name: openhab
uid: 9001
state: present
system: yes
update_password: on_create
create_home: no
group: openhab
- name: Create openHAB Directories
file:
path: "{{ item }}"
state: directory
owner: openhab
group: openhab
with_items:
- "{{ openhab_data_directory }}"
- "{{ openhab_data_directory }}/conf"
- "{{ openhab_data_directory }}/userdata"
- "{{ openhab_data_directory }}/addons"
- name: Create openHAB container
docker_container:
name: openHAB
image: "{{ openhab_docker_image }}"
pull: true
network_mode: "host"
volumes:
- "{{ openhab_data_directory }}/conf:/openhab/conf:rw"
- "{{ openhab_data_directory }}/userdata:/openhab/userdata:rw"
- "{{ openhab_data_directory }}/addons:/openhab/addons:rw"
- "/etc/localtime:/etc/localtime:ro"
- "/etc/timezone:/etc/timezone:ro"
env:
OPENHAB_HTTP_PORT: "{{ openhab_port_http }}"
OPENHAB_HTTPS_PORT: "{{ openhab_port_https }}"
restart_policy: unless-stopped
memory: 1g
labels:
traefik.enable: "{{ openhab_available_externally }}"
traefik.http.routers.openhab.rule: "Host(`openhab.{{ ansible_nas_domain }}`)"
traefik.http.routers.openhab.tls.certresolver: "letsencrypt"
traefik.http.routers.openhab.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.openhab.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.openhab.loadbalancer.server.port: "7777"