Created
May 16, 2023 20:44
-
-
Save joseche/7ec223039622350385301dff48f4f2dc to your computer and use it in GitHub Desktop.
ansible check disk and service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - name: Check disk space and service status | |
| hosts: compute_nodes | |
| gather_facts: true | |
| tasks: | |
| - name: Check disk space | |
| ansible.builtin.shell: | | |
| df -h|awk '{if(int($5)>10){print $1, $5; exit 1}}' | |
| changed_when: false | |
| - name: Check services | |
| service_facts: | |
| - name: Fail when the service is down | |
| ansible.builtin.fail: | |
| msg: | |
| when: ansible_facts.services['gdm.service']['state'] != 'running' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment