initial commit

This commit is contained in:
2025-08-19 11:40:26 -07:00
commit c34b325cf0
18 changed files with 1803 additions and 0 deletions

102
tasks/sd_handler.yaml Normal file
View File

@ -0,0 +1,102 @@
---
# when ran, this will look for an SD card
# optionally format it
# map it to working_storage
# can only run on arm64
# '"arm64" in cpu_architecture'
- name: Video Capture - Check for SD
shell: "df"
register: df_check_output
- name: Video Capture - Set sd_unmounted
when: working_storage in df_check_output.stdout
set_fact:
sd_unmounted: false
- name: Video Capture - Set arm_arch
when: '"arm64" in cpu_architecture'
set_fact:
arm_arch: true
- name: SD Handler - Checks have passed
when: sd_unmounted and arm_arch | bool
block:
- name: SD Handler - format SD card
when: format_sd | bool
block:
- name: dummy task
debug:
msg: "nothing to see here, move along"
- name: SD Handler - find SD card
block:
- name: SD Handler - get boot device
shell: "blkid | grep '\"boot\"' | cut -d: -f 1 | cut -d/ -f 3 | cut -dp -f 1"
register: boot_device
- name: SD Handler - get sd card device
shell: "lsblk -o NAME,SIZE --nodeps | grep -v -e loop -e {{ boot_device.stdout_lines[0] }} -e NAME | cut -d ' ' -f 1"
register: sd_card_device
- name: SD Handler - get sd card uuid
shell: "blkid | grep {{ sd_card_device.stdout_lines[0] }} | awk '{for (i=1; i<=NF; i++) print $i}' | grep UUID | grep -v PART | cut -d '\"' -f 2"
register: sd_card_uuid_output
- name: SD Handler - set uuid variable
set_fact:
sd_card_uuid: "{{ sd_card_uuid_output.stdout_lines[0] }}"
- debug:
msg: "UUID Found: {{ sd_card_uuid }}"
- name: SD Handler - mount sd card
block:
- name: SD Handler - check folder
file:
path: "{{ working_storage }}"
state: directory
mode: '0755'
owner: root
group: root
- name: SD Handler - Generate fstab entry
set_fact:
fstab_line_sd: "UUID={{ sd_card_uuid }} {{ working_storage }} ext4 errors=remount-ro 0 1"
- name: SD Handler - add fstab entry
lineinfile:
path: "/etc/fstab"
search_string: "{{ sd_card_uuid }}"
line: "{{ fstab_line_sd }}"
- debug:
msg: |
fstab entry:
{{ fstab_line_sd }}
- name: SD Handler - daemon reload
systemd:
daemon_reload: yes
- name: SD Handler - Mount it
shell: mount -a
- name: SD Handler - validate this
block:
- name: SD Handler - check for new mount point
shell: "df -h | grep -e Size -e {{ working_storage }}"
register: sd_test_output
- debug:
msg: "{{ sd_test_output.stdout_lines }}"
...