mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Renamed health services
This commit is contained in:
2
roles/health-disc-space/README.md
Normal file
2
roles/health-disc-space/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# health-disc-space
|
||||
Checks if enough disc space is free
|
15
roles/health-disc-space/files/health-disc-space.sh
Normal file
15
roles/health-disc-space/files/health-disc-space.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# @param $1 mimimum free disc space
|
||||
errors=0
|
||||
minimum_percent_free_disc_space="$1"
|
||||
echo "checking disc space use..."
|
||||
df
|
||||
for disc_use_percent in $(df --output=pcent | sed 1d)
|
||||
do
|
||||
disc_use_percent_number=$(echo "$disc_use_percent" | sed "s/%//")
|
||||
if [ "$disc_use_percent_number" -gt "$minimum_percent_free_disc_space" ]; then
|
||||
echo "WARNING: $disc_use_percent_number exceeds the limit of $minimum_percent_free_disc_space%."
|
||||
errors+=1;
|
||||
fi
|
||||
done
|
||||
exit $errors;
|
12
roles/health-disc-space/handlers/main.yml
Normal file
12
roles/health-disc-space/handlers/main.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
- name: "reload health-disc-space.service"
|
||||
systemd:
|
||||
name: health-disc-space.service
|
||||
state: reloaded
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
||||
- name: "restart health-disc-space.timer"
|
||||
systemd:
|
||||
name: health-disc-space.timer
|
||||
state: restarted
|
||||
enabled: yes
|
||||
daemon_reload: yes
|
2
roles/health-disc-space/meta/main.yml
Normal file
2
roles/health-disc-space/meta/main.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- systemd_notifier
|
22
roles/health-disc-space/tasks/main.yml
Normal file
22
roles/health-disc-space/tasks/main.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
- name: "create {{disc_space_check_folder}}"
|
||||
file:
|
||||
path: "{{disc_space_check_folder}}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: create health-disc-space.sh
|
||||
copy:
|
||||
src: health-disc-space.sh
|
||||
dest: "{{disc_space_check_folder}}health-disc-space.sh"
|
||||
|
||||
- name: create health-disc-space.service
|
||||
template:
|
||||
src: health-disc-space.service.j2
|
||||
dest: /etc/systemd/system/health-disc-space.service
|
||||
notify: reload health-disc-space.service
|
||||
|
||||
- name: create health-disc-space.timer
|
||||
template:
|
||||
src: health-disc-space.timer.j2
|
||||
dest: /etc/systemd/system/health-disc-space.timer
|
||||
notify: restart health-disc-space.timer
|
@@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=checking disc space
|
||||
OnFailure=systemd-notifier@%n.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash {{disc_space_check_folder}}health-disc-space.sh {{size_percent_disc_space_warning}}
|
10
roles/health-disc-space/templates/health-disc-space.timer.j2
Normal file
10
roles/health-disc-space/templates/health-disc-space.timer.j2
Normal file
@@ -0,0 +1,10 @@
|
||||
[Unit]
|
||||
Description=starts health-disc-space.service
|
||||
|
||||
[Timer]
|
||||
OnCalendar={{on_calendar_disc_space_check}}
|
||||
RandomizedDelaySec={{randomized_delay_sec}}
|
||||
Persistent=true
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
1
roles/health-disc-space/vars/main.yml
Normal file
1
roles/health-disc-space/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
disc_space_check_folder: "{{path_administrator_scripts}}health-disc-space/"
|
Reference in New Issue
Block a user