ansible-nas/roles/homebridge/tasks/main.yml
2023-03-09 21:47:42 +01:00

44 lines
1.7 KiB
YAML

---
- name: Start Homebridge
block:
- name: Create Homebridge Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
# mode: 0755
with_items:
- "{{ homebridge_config_directory }}"
- name: Create Homebridge Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ homebridge_container_name }}"
image: "{{ homebridge_image_name }}:{{ homebridge_image_version }}"
pull: true
volumes:
- "{{ homebridge_config_directory }}:/homebridge"
network_mode: "host"
env:
TZ: "{{ ansible_nas_timezone }}"
PGID: "{{ homebridge_group_id }}"
PUID: "{{ homebridge_user_id }}"
HOMEBRIDGE_CONFIG_UI: "1"
HOMEBRIDGE_CONFIG_UI_PORT: "{{ homebridge_port }}"
restart_policy: unless-stopped
memory: "{{ homebridge_memory }}"
labels:
traefik.enable: "{{ homebridge_available_externally | string }}"
traefik.http.routers.homebridge.rule: "Host(`{{ homebridge_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.homebridge.tls.certresolver: "letsencrypt"
traefik.http.routers.homebridge.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.homebridge.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.homebridge.loadbalancer.server.port: "8087"
when: homebridge_enabled is true
- name: Stop Homebridge
block:
- name: Stop Homebridge
community.docker.docker_container:
name: "{{ homebridge_container_name }}"
state: absent
when: homebridge_enabled is false