From 48abdc5f6b14947c0641049a1e828e447ddec9df Mon Sep 17 00:00:00 2001 From: WhatTheMike Date: Tue, 13 Feb 2024 18:36:34 +0000 Subject: [PATCH] Cleaned up rpi stuffs --- playbooks/rpi-basics.yaml | 10 +++++++++ playbooks/rpi-model.yaml | 15 +++++++++++++ playbooks/rpi-watchdog.yaml | 33 ---------------------------- roles/rpi_scripts/files/rpi-model.sh | 11 ++++++++++ roles/rpi_scripts/files/rpi-temp.sh | 6 +++++ roles/rpi_scripts/tasks/main.yaml | 23 +++++++++++++++++++ roles/rpi_watchdog/tasks/main.yaml | 28 +++++++++++++++++++++++ 7 files changed, 93 insertions(+), 33 deletions(-) create mode 100644 playbooks/rpi-basics.yaml create mode 100644 playbooks/rpi-model.yaml delete mode 100644 playbooks/rpi-watchdog.yaml create mode 100644 roles/rpi_scripts/files/rpi-model.sh create mode 100644 roles/rpi_scripts/files/rpi-temp.sh create mode 100644 roles/rpi_scripts/tasks/main.yaml create mode 100644 roles/rpi_watchdog/tasks/main.yaml diff --git a/playbooks/rpi-basics.yaml b/playbooks/rpi-basics.yaml new file mode 100644 index 0000000..fb3e557 --- /dev/null +++ b/playbooks/rpi-basics.yaml @@ -0,0 +1,10 @@ +--- +- name: Ensures basic scripts & configs set up for Raspberry Pis + hosts: raspberries + tasks: + - name: Include the rpi_scripts role + include_role: + name: rpi_scripts + - name: Include the rpi_watchdog role + include_role: + name: rpi_watchdog diff --git a/playbooks/rpi-model.yaml b/playbooks/rpi-model.yaml new file mode 100644 index 0000000..e09443c --- /dev/null +++ b/playbooks/rpi-model.yaml @@ -0,0 +1,15 @@ +--- +- name: Gets models for raspberry pies (raspberries) + hosts: raspberries + tasks: + - name: Include the rpi_scripts role + include_role: + name: rpi_scripts + - name: Execute model script + ansible.builtin.command: + chdir: /home/pi/bin + cmd: ./model + register: stdout + - name: Display raspberry models + debug: + var=stdout.stdout diff --git a/playbooks/rpi-watchdog.yaml b/playbooks/rpi-watchdog.yaml deleted file mode 100644 index ed18ecb..0000000 --- a/playbooks/rpi-watchdog.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- name: Configure watchdog on raspberry pis - hosts: raspberries - tasks: - # https://raspberrypi.stackexchange.com/a/99625 - - name: Configure watchdog runtime to 10 sec - ansible.builtin.replace: - regexp: '#?RuntimeWatchdogSec=\d+' - replace: 'RuntimeWatchdogSec=10' - path: /etc/systemd/system.conf - become: true - become_method: sudo - register: runtime_watchdoggo - - name: Configure watchdog shutdown timer to 10 min - ansible.builtin.replace: - regexp: '#?ShutdownWatchdogSec=\d+[a-z]*' - replace: 'ShutdownWatchdogSec=10min' - path: /etc/systemd/system.conf - become: true - become_method: sudo - register: shutdown_watchdoggo - - - name: Reload systemd if needed - ansible.builtin.systemd_service: - daemon_reload: true - become: true - become_method: sudo - when: runtime_watchdoggo.changed or shutdown_watchdoggo.changed - - -#RuntimeWatchdogSec=0 -#ShutdownWatchdogSec=10min - diff --git a/roles/rpi_scripts/files/rpi-model.sh b/roles/rpi_scripts/files/rpi-model.sh new file mode 100644 index 0000000..303d189 --- /dev/null +++ b/roles/rpi_scripts/files/rpi-model.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# For determining the hardware version of a Raspberry Pi +# https://stackoverflow.com/a/46163991 + +model="" +while IFS= read -r -d '' substring || [[ $substring ]]; do + model+="$substring" +done