Added zoneminder to aya01 (if I hadn't before)

Added backblaze (todo documentation)

Signed-off-by: TuDatTr <tuan-dat.tran@tudattr.dev>
pull/1/head
TuDatTr 2022-12-06 16:36:21 +01:00
parent 70083f2974
commit b371e246a9
16 changed files with 150 additions and 11 deletions

View File

@ -25,7 +25,7 @@
```
- copy public key to remote system
`ssh-copy-id -i /mnt/veracrypt1/genesis.pub aya01`
- Adjust ansible inventory
- Add this host to ansible inventory
- Install sudo on remote
- add user to sudo group (with `su --login` without login the path will not be loaded correctly see [here](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=918754)) and `usermod -a -G sudo tudattr`
- set time correctly when getting the following error
@ -38,6 +38,16 @@ sudo systemctl stop ntp.service
sudo ntpd -gq
sudo systemctl start ntp.service
```
### zoneminder
- Enable authentification in (Option->System)
- Create new Camera:
- General>Name: BirdCam
- General>Function: Ffmpeg
- General>Function: Modect
- Source>Source Path: `rtsp://user:pw@ip:554/cam/mpeg4`
- Change default admin password
- Create users
## RaspberryPi

View File

@ -4,5 +4,6 @@
gather_facts: yes
roles:
- role: common
- role: backblaze
- role: power_management
- role: docker

View File

@ -4,6 +4,22 @@
user: tudattr
timezone: Europe/Berlin
local_domain: borg.land
rclone_config: "/root/.config/rclone/"
#
# aya01 - Disks
#
fstab_entries:
- name: "config"
uuid: "4942deb8-707e-48b5-81e3-555ae3cda9ba"
type: "ext4"
path: "/opt/"
- name: "media"
uuid: "c4c724ec-4fe3-4665-adf4-acd31d6b7f95"
type: "ext4"
path: "/media/"
#
# Packages
@ -17,6 +33,7 @@ common_packages:
- smartmontools
- curl
- tree
- rsync
#
# Docker
@ -29,5 +46,28 @@ docker_apt_repository: "deb [arch={{ docker_apt_arch }}] {{ docker_repo_url }}/{
docker_compose_dir: /opt/docker/compose
docker_dir: /opt/docker/config
docker_data_dir: /media/docker/data # only available on aya01
mysql_user: user
#
# aya01
#
zoneminder_config: "{{ docker_dir }}/zm/"
zoneminder_data: "{{ docker_data_dir }}/zm/data"
#
# pi
#
#
# backblaze
#
backblaze_paths:
aya01:
- "{{ docker_compose_dir }}"
- "{{ docker_dir }}"
pi:
- "{{ docker_compose_dir }}"
- "{{ docker_dir }}"

2
pi.yml
View File

@ -4,4 +4,6 @@
gather_facts: yes
roles:
- common
- backblaze
- docker

View File

@ -0,0 +1,6 @@
---
- name: Loop over subelements of the dictionary
shell:
cmd: "rclone -vv sync {{ item.1 }} secret:{{ item.1 }}"
when: item.0.key == inventory_hostname
loop: "{{ backblaze_paths | dict2items | subelements('value') }}"

View File

@ -0,0 +1,18 @@
---
- name: Create rclone config folder at "{{ rclone_config }}"
file:
path: "{{ rclone_config }}"
owner: '0'
group: '0'
mode: '700'
state: directory
become: true
- name: Copy rclone config to "{{ inventory_hostname }}"
template:
src: "templates/{{ inventory_hostname }}/rclone.conf"
dest: "{{ rclone_config }}/rclone.conf"
owner: '0'
group: '0'
mode: '400'
become: true

View File

@ -0,0 +1,13 @@
---
- name: Update and upgrade packages
apt:
update_cache: yes
upgrade: yes
autoremove: yes
become: yes
- name: Install rclone
apt:
name: "rclone"
state: present
become: yes

View File

@ -0,0 +1,5 @@
---
- include_tasks: install.yml
- include_tasks: config.yml
- include_tasks: backup.yml

View File

@ -0,0 +1,10 @@
[remote]
type = b2
account = {{ vault_backblaze_aya01_account }}
key = {{ vault_backblaze_aya01_key }}
[secret]
type = crypt
remote = remote:aya01-tudattr-dev
password = {{ vault_rclone_aya01_password }}
password2 = {{ vault_rclone_aya01_password2 }}

View File

@ -0,0 +1,10 @@
[remote]
type = b2
account = {{ vault_backblaze_pi_account }}
key = {{ vault_backblaze_pi_key }}
[secret]
type = crypt
remote = remote:pi-tudattr-dev
password = {{ vault_rclone_pi_password }}
password2 = {{ vault_rclone_pi_password2 }}

View File

@ -0,0 +1,21 @@
---
- name: Create folders to mount to
file:
path: "{{ item.path }}"
state: directory
loop: "{{ fstab_entries }}"
become: true
- name: Create fstab entries
mount:
src: "UUID={{ item.uuid }}"
path: "{{ item.path }}"
fstype: "{{ item.type }}"
state: present
backup: true
loop: "{{ fstab_entries }}"
become: true
- name: Mount all disks
command: mount -a
become: true

View File

@ -2,4 +2,4 @@
- include_tasks: time.yml
- include_tasks: essential.yml
- include_tasks: aya01_fstab.yml
when: ansible_hostname == "aya01"
when: inventory_hostname == "aya01"

View File

@ -6,7 +6,9 @@
mode: '700'
state: directory
loop:
- "{{ docker_dir }}/zm/"
- "{{ zoneminder_data }}"
- "{{ zoneminder_config }}"
become: true
# Todo, check if docker compose is running
# - name: Shut down docker

View File

@ -2,6 +2,6 @@
- include_tasks: install.yml
- include_tasks: user_group_setup.yml
- include_tasks: pi_compose.yml
when: ansible_hostname == "pi"
when: inventory_hostname == "pi"
- include_tasks: aya01_compose.yml
when: ansible_hostname == "aya01"
when: inventory_hostname == "aya01"

View File

@ -7,7 +7,7 @@ services:
- zoneminder
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ docker_dir }}/zm/db:/var/lib/mysql"
- "{{ zoneminder_config}}/db:/var/lib/mysql"
environment:
- "MYSQL_DATABASE=zm"
- "MYSQL_ROOT_PASSWORD={{ vault_mysql_root_password }}"
@ -30,9 +30,9 @@ services:
- net
volumes:
- "/etc/localtime:/etc/localtime:ro"
- "{{ docker_dir }}/zm/data:/data"
- "{{ docker_dir }}/zm/config:/config"
- "{{ docker_dir }}/zm/log:/log"
- "{{ zoneminder_data }}:/data"
- "{{ zoneminder_config }}/config:/config"
- "{{ zoneminder_config }}/log:/log"
- type: tmpfs
target: /dev/shm
tmpfs:
@ -51,7 +51,8 @@ networks:
net:
driver: bridge
ipam:
driver: default
# driver: default
config:
- subnet: 172.16.69.0/24
ip_range: 172.28.69.0/24
gateway: 172.16.69.1

View File

@ -80,7 +80,7 @@ networks:
net:
driver: bridge
ipam:
driver: default
# driver: default
config:
- subnet: 172.16.69.0/24
gateway: 172.16.69.1