# Plabook for Ansible to scan for faulty monit configuration (based on T224850)
# missing 'set alert...' line in '/etc/monit/monitrc'

# This playbook must be started from the main folder to access the dynamic
# data-dir inventory.
# Start with:
# ansible-playbook \
#    playbooks/T224850_monit_set-alert/scan.yml --diff --limit hostname


- name: scan T224850_monit_set-alert
  gather_facts: no
  hosts: all
  ignore_unreachable: yes
  # Hosts at Peter Lacke will be handled one by one with a pause in-between
  serial: 2

  tasks:
  - name: grep in monitrc (check if line is active)
    tags: grepstatement
    become: true
    shell: 'grep -E "^[^#]*[\s]*set alert monitoring@perfact.de" /etc/monit/monitrc'
    register: scanfile_output
    ignore_errors: yes