frigate/start.yaml

52 lines
1.9 KiB
YAML

- name: Start Frigate
hosts: Barad-dur
tasks:
- name: Create temporary Docker Compose directory
ansible.builtin.tempfile:
state: directory
register: docker_compose_dir
- name: Copy docker-compose.yaml
ansible.builtin.copy:
src: conf/docker-compose.yaml
dest: '{{docker_compose_dir.path}}/docker-compose.yaml'
mode: preserve
- name: Read homelab config
ansible.builtin.slurp:
src: '{{ansible_user_dir}}/.homelab.json'
register: homelab_config_file
- name: Set homelab_config variable
ansible.builtin.set_fact:
homelab_config: '{{homelab_config_file.content|b64decode|from_json}}'
- name: Get Frigate config
community.postgresql.postgresql_query:
login_host: '{{homelab_config.database.host}}'
login_user: '{{homelab_config.database.user}}'
login_password: '{{homelab_config.database.password}}'
db: '{{homelab_config.database.name}}'
query: 'SELECT config FROM service WHERE name = %s;'
positional_args:
- frigate
register: frigate_config_query
- name: Set frigate_config variable
ansible.builtin.set_fact:
frigate_config: '{{frigate_config_query.query_result[0].config}}'
- name: Docker Compose up Frigate
environment:
FRIGATE_MQTT_PASSWORD: '{{frigate_config.mqtt.password}}'
FRIGATE_GARAGE_RTSP_PASSWORD: '{{frigate_config.rtsp.garage.password}}'
FRIGATE_FRONT_DOOR_RTSP_PASSWORD: '{{frigate_config.rtsp.front_door.password}}'
FRIGATE_BACK_DOOR_RTSP_PASSWORD: '{{frigate_config.rtsp.back_door.password}}'
FRIGATE_FAMILY_ROOM_RTSP_PASSWORD: '{{frigate_config.rtsp.family_room.password}}'
community.docker.docker_compose:
project_name: frigate
project_src: '{{docker_compose_dir.path}}'
state: present
- name: Remove temporary Docker Compose directory
ansible.builtin.file:
path: '{{docker_compose_dir.path}}'
state: absent