Skip to content

Instantly share code, notes, and snippets.

@nmartins0611
Created August 22, 2023 09:24
Show Gist options
  • Save nmartins0611/4a680e32382c0f811c5240223247b291 to your computer and use it in GitHub Desktop.
Save nmartins0611/4a680e32382c0f811c5240223247b291 to your computer and use it in GitHub Desktop.
Rulebook to filter chat messages
## example
---
- name: Listen for events on a webhook
hosts: all
sources:
- ansible.eda.webhook:
host: 0.0.0.0
port: 5000
rules:
- name: Filter payload for hostnames
condition: event.payload.text is match("backup") ## backup is the trigger word set in mattermost
action:
run_playbook:
name: filter_regex.yml ## playbook to filter text payload - we want the hostnames
post_events: true
- name: Backup specified switch
condition: event.switch_devices is defined ## switch_devices is the fact set in the previous playbook
action:
run_playbook:
Name: switch_backup.yml ## Backup playbook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment