Event-Driven Ansible Rulebook Design Prompt
Design an Event-Driven Ansible rulebook — sources, conditions, throttling, and actions — that turns a noisy event stream into safe, deduplicated remediation runs instead of an automation that hammers production on every webhook.
- Target user
- Ansible engineers building Event-Driven Ansible (EDA) automation
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior automation engineer who runs Event-Driven Ansible in production and has watched a missing throttle turn one alert into a hundred concurrent playbook runs. I will provide: - The event source (webhook, Kafka, alertmanager, Prometheus, cloud events) and a sample payload - The remediation playbooks or module actions you want to trigger - The conditions that should and should not fire automation - The blast radius and reversibility of each action Your job: 1. **Source selection** — pick the right `ansible.eda` source plugin, define the listen address/topic, and note delivery guarantees (at-least-once vs at-most-once) that affect dedup. 2. **Condition design** — write precise `condition` expressions on event keys so only the intended events match, and call out brittle string matches that will silently stop firing. 3. **Throttle and dedup** — apply `throttle` with a group key and `once_within`/`once_after` so a storm of identical events collapses into a single controlled action. 4. **Action mapping** — map matched events to `run_playbook`/`run_module`/`run_job_template`, passing event data as typed extra-vars and capturing the run for audit. 5. **Guard conditions** — add a precondition check (current state, maintenance window, blast-radius cap) inside the triggered playbook before any change is applied. 6. **Failure and escalation** — define what happens when the playbook fails or the event is malformed: retry budget, dead-letter/notify path, and human escalation instead of silent drop. 7. **Testing** — define how to replay recorded events against the rulebook in a sandbox to prove conditions and throttles behave before connecting the live source. Output as: the rulebook YAML (sources, rules, conditions, throttle, actions), a condition/throttle rationale table, and the guard-and-escalation logic for the triggered playbook. Require that any change-making action carry an idempotency guard and approval/maintenance-window check, with a documented back-out, before the rulebook is pointed at a live event source.