parent
ed6116f9c5
commit
48abdc5f6b
@ -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
|
@ -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
|
@ -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
|
||||
|
@ -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 </proc/device-tree/model
|
||||
|
||||
|
||||
echo $model
|
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
if [[ -z $1 ]]; then
|
||||
vcgencmd measure_temp | sed "s/'/°/g"
|
||||
else
|
||||
vcgencmd measure_temp | sed "s/'/°/g" | cut -d= -f2
|
||||
fi
|
@ -0,0 +1,23 @@
|
||||
---
|
||||
# Model script
|
||||
- name: Confirm directory structure
|
||||
ansible.builtin.file:
|
||||
path: /home/pi/bin
|
||||
state: directory
|
||||
- name: Ensure raspberry pi model script is present
|
||||
ansible.builtin.copy:
|
||||
src: rpi-model.sh
|
||||
dest: /home/pi/bin/model
|
||||
mode: '0755'
|
||||
force: yes
|
||||
# Temperature script
|
||||
- name: Confirm directory structure
|
||||
ansible.builtin.file:
|
||||
path: /home/pi/bin
|
||||
state: directory
|
||||
- name: Ensure raspberry pi temp script is present
|
||||
ansible.builtin.copy:
|
||||
src: rpi-temp.sh
|
||||
dest: /home/pi/bin/temp
|
||||
mode: '0755'
|
||||
force: yes
|
@ -0,0 +1,28 @@
|
||||
---
|
||||
# https://raspberrypi.stackexchange.com/a/99625
|
||||
- name: Configure watchdog runtime to 10 sec
|
||||
ansible.builtin.replace:
|
||||
# Looking for line: #RuntimeWatchdogSec=0
|
||||
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:
|
||||
# Looking for line #ShutdownWatchdogSec=10min
|
||||
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
|
||||
|
Loading…
Reference in new issue