In the past few articles, we explored how to use different event sources in Ansible Event-Driven Automation (EDA). In this demo, we’ll focus on how event filters can help clean up and simplify event data, making automation easier to manage. Specifically, we’ll explore the ansible.eda.dashes_to_underscores event filter and how it works.

When using Ansible EDA with tools like webhooks, Prometheus, or cloud services, events often come in as JSON data. These JSON payloads usually have keys with dashes in their names, like alert-name or instance-id. While this is fine in JSON, it becomes a problem in Ansible because variable names with dashes can’t be used directly in playbooks or Jinja2 templates. The dashes_to_underscores filter helps solve this issue by converting those dashed keys into names that Ansible can work with more easily.

Leave a Reply

Your email address will not be published. Required fields are marked *