Skip to content

Instantly share code, notes, and snippets.

@joseche
Created May 16, 2023 20:44
Show Gist options
  • Select an option

  • Save joseche/7ec223039622350385301dff48f4f2dc to your computer and use it in GitHub Desktop.

Select an option

Save joseche/7ec223039622350385301dff48f4f2dc to your computer and use it in GitHub Desktop.
ansible check disk and service
---
- 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