Added Frigate and samba share roles

This commit is contained in:
Annika Merris 2026-01-30 23:53:02 +00:00
parent a9c0520bbf
commit b37884ffd6
10 changed files with 151 additions and 1 deletions

View file

@ -0,0 +1,46 @@
---
- name: Load distro-specific variables
ansible.builtin.include_vars: '{{ item }}'
tags: always
with_first_found:
- files:
- "{{ ansible_facts['distribution'] }}.yaml"
skip: true
- name: Ensure frigate is running on this device
block:
- name: Ensure presense of folders for frigate
tags: packages,docker,frigate
ansible.builtin.file:
path: /opt/frigate/config
state: directory
recurse: true
owner: 1000
group: 1000
mode: "0755"
- name: Ensure compose files are properly loaded on the server
tags: packages,docker,frigate
ansible.builtin.template:
src: docker-compose.yaml.j2
dest: /opt/frigate/docker-compose.yaml
owner: 1000
group: 1000
mode: "0644"
# - name: Ensure frigate config is available for container
# tags: packages,frigate
# ansible.builtin.template:
# src: frigate-config.yaml.j2
# dest: /opt/frigate/config/server.yml
# owner: 1000
# group: 1000
# mode: "0644"
- name: Ensure docker containers are pulled and running
tags: packages,docker,frigate
community.docker.docker_compose_v2:
project_src: /opt/frigate
pull: policy
rescue:
- name: Set that this task failed
ansible.builtin.set_fact:
task_failed: true

View file

@ -0,0 +1,27 @@
---
services:
frigate:
container_name: frigate
# privileged: true # this may not be necessary for all setups
restart: unless-stopped
stop_grace_period: 30s # allow enough time to shut down the various services
image: ghcr.io/blakeblackshear/frigate:{{ frigate_image_tag }}
shm_size: "512mb" # update for your cameras based on calculation above
devices:
- /dev/dri/renderD128:/dev/dri/renderD128 # For intel hwaccel, needs to be updated for your hardware
volumes:
- /etc/localtime:/etc/localtime:ro
- /opt/frigate/config:/config
- /mnt/service-storage:/media/frigate
- type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "8971:8971"
# - "5000:5000" # Internal unauthenticated access. Expose carefully.
- "8554:8554" # RTSP feeds
- "8555:8555/tcp" # WebRTC over tcp
- "8555:8555/udp" # WebRTC over udp
environment:
FRIGATE_RTSP_PASSWORD: "{{ frigate_rtsp_passwd }}"

View file

@ -0,0 +1,9 @@
---
frigate_rtsp_passwd: !vault |
$ANSIBLE_VAULT;1.1;AES256
32303838626238633166343130626263383237356566363830656432373637626237366162396131
3439633565626161303538353462636363323961656462300a323338383533386136376638376230
31363135633230333637366438346331656632353565323837356330363934656232333063646264
3561646234623133330a323731336437383438633630393065343363306636343634663162656539
3162
frigate_image_tag: 0.16.4

View file

@ -0,0 +1,41 @@
---
- name: Load distro-specific variables
ansible.builtin.include_vars: '{{ item }}'
tags: always
with_first_found:
- files:
- "{{ ansible_facts['distribution'] }}.yaml"
skip: true
- name: Ensure frigate is running on this device
block:
- name: Ensure mount point exists
tags: mount
ansible.builtin.file:
path: /mnt/service_storage
state: directory
recurse: true
owner: 1000
group: 1000
mode: "0775"
- name: Ensure mount settings are placed in fstab and the share is mounted
tags: nas,samba,mount
ansible.posix.mount:
path: /mnt/service_storage
src: //10.69.2.20/service_storage
fstype: cifs
opts: _netdev,x-systemd,automount,noatime,uid=1000,gid=1000,dir_mode=0775,file_mode=0775,credentials=/root/.smbcredentials
state: mounted
- name: Ensure share credentials are stored on the server
tags: nas,samba,credentials
ansible.builtin.template:
src: smbcredentials.j2
dest: /root/.smbcredentials
owner: root
group: root
mode: "0600"
rescue:
- name: Set that this task failed
ansible.builtin.set_fact:
task_failed: true

View file

@ -0,0 +1,2 @@
username={{ service_share_smb_username }}
password={{ service_share_smb_password }}

View file

@ -0,0 +1,9 @@
---
service_share_smb_password: !vault |
$ANSIBLE_VAULT;1.1;AES256
64363432323165386364323936663133396531316363646662616666343166326364356532646362
3265373066363734303930366638306461346435313234330a643361323764326135303936333363
31376433363166646335376265656266343335383864613266383131663165653630393663363062
6339633639653031330a613336376133363034663363663430396532663131613664643963353531
6130
service_share_smb_username: annika