update
This commit is contained in:
23
Playbooks/servers/update-diskspace.yml
Normal file
23
Playbooks/servers/update-diskspace.yml
Normal file
@ -0,0 +1,23 @@
|
||||
- hosts: "{{ hosts }}"
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Get disk usage
|
||||
command: df -h
|
||||
register: disk_usage
|
||||
|
||||
- name: Check disk space available
|
||||
shell: df -h / | awk 'NR==2 {print $5}'
|
||||
register: disk_usage
|
||||
|
||||
# Send Discord message when disk space is over 80%
|
||||
- name: Send Discord message
|
||||
uri:
|
||||
url: "{{ discord_webhook_url }}"
|
||||
method: POST
|
||||
body_format: json
|
||||
body: '{"content": "Disk space on {{ inventory_hostname }} is above 80%!"}'
|
||||
headers:
|
||||
Content-Type: application/json
|
||||
status_code: 204
|
||||
when: disk_usage.stdout[:-1]|int > 80
|
Reference in New Issue
Block a user