feat: Frigate

Co-authored-by: Lino Silva <lino.silva@farfetch.com>
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
lino
2022-11-25 23:29:38 +00:00
parent 5075a3e697
commit 508e433bab
27 changed files with 370 additions and 52 deletions
+20
View File
@@ -0,0 +1,20 @@
---
- name: Create directory for docker-compose
ansible.builtin.file:
path: /root/docker/frigate/
state: directory
mode: "0755"
- name: Copy docker-compose file
template:
src: "docker-compose.yml"
dest: /root/docker/frigate/docker-compose.yml
owner: root
group: root
mode: 0755
- name: Run docker-compose
ansible.builtin.shell:
args:
cmd: docker compose up -d
chdir: /root/docker/frigate/
@@ -0,0 +1,20 @@
version: "3.9"
services:
frigate:
container_name: frigate
privileged: true
restart: unless-stopped
image: blakeblackshear/frigate:stable
shm_size: "256mb"
devices:
- /dev/bus/usb:/dev/bus/usb
volumes:
- /etc/localtime:/etc/localtime:ro
- /config/config.yml:/config/config.yml:ro
- /db:/db
- type: tmpfs
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "5000:5000"
@@ -0,0 +1,11 @@
---
- name: Get convenience script
uri:
url: "https://get.docker.com"
method: GET
dest: /tmp/get-docker.sh
mode: a+x
creates: /tmp/get-docker.sh
- name: Execute script
ansible.builtin.shell: /tmp/get-docker.sh
@@ -0,0 +1,16 @@
---
- name: Add cgroup rule
ansible.builtin.blockinfile:
path: /etc/pve/nodes/epona/lxc/605.conf
state: present
block: |
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.apparmor.profile: unconfined
lxc.cgroup2.devices.allow: a
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file 0, 0
lxc.mount.entry: /dev/bus/usb/002 dev/bus/usb/002 none bind,optional,create=dir 0, 0
lxc.cap.drop:
lxc.mount.auto: cgroup:rw
@@ -0,0 +1,28 @@
---
- name: Create container
community.general.proxmox:
vmid: 605
node: epona
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
password: "{{ lxc_password }}"
hostname: frigate
ostemplate: "hyrule-8tb-nfs:vztmpl/debian-11-standard_11.3-1_amd64.tar.zst"
netif: "{'net0':'name=eth0,\
gw=10.0.0.1,\
ip=10.0.2.14/21,\
hwaddr=44:ae:9f:cd:b9:2a,\
bridge=vmbr0'}"
cores: 1
memory: 6144
unprivileged: no
swap: 0
searchdomain: "home"
onboot: 1
mounts: '{"mp0":"/mnt/pve/hyrule-8tb-nfs/frigate/config,mp=/config","mp1":"/mnt/pve/hyrule-8tb-nfs/frigate/media,mp=/media/frigate","mp2":"local-lvm:16,mp=/db"}'
features:
- nesting=1
- keyctl=1
disk: local-lvm:30
force: yes
@@ -0,0 +1,26 @@
---
- name: Stop container
community.general.proxmox:
vmid: 605
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: stopped
ignore_errors: true
timeout: 90
- name: Remove containers
community.general.proxmox:
vmid: 605
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: absent
ignore_errors: true
timeout: 90
- name: Remove .ssh/known_hosts lines
ansible.builtin.lineinfile:
path: /Users/lino.silva/.ssh/known_hosts
state: absent
regexp: "^10.0.2.14"
@@ -0,0 +1,8 @@
---
# Unable to use ansible.builtin.lineinfile, because we need to run this through the proxmox host (because SSH is not enabled duh)
- name: Allow SSH into LXC
ansible.builtin.command: lxc-attach -n 605 -- sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
- name: Restart SSH Service
ansible.builtin.command: lxc-attach -n 605 service ssh restart
@@ -0,0 +1,8 @@
---
- name: Start deployments
community.general.proxmox:
vmid: 605
api_user: root@pam
api_password: "{{ proxmox_api_password }}"
api_host: 10.0.2.2
state: started
+6
View File
@@ -0,0 +1,6 @@
---
- name: Update all packages to their latest version
ansible.builtin.apt:
name: "*"
update_cache: yes
state: latest