Event Driven Ansible and target hosts in rulebooks

Hi,

I want to write a rulebook that triggers a playbook run on some specific event. Basically I want to configure an interface of a router. My event passes all the interface data in the event.payload.data.

The core part of the runbook looks like:

action:
run_playbook:
name: set_interface.yml
extra_vars:
interface: “{{ event.payload.data }}”

The rule is triggered and the playbook starts to run. BUT the playbook does not know which host to target. The output is:

2024-03-06 15:42:52,146 - ansible_rulebook.action.run_playbook - DEBUG - Calling Ansible runner
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match ‘all’

PLAY [Test playbook] ***********************************************************
skipping: no hosts matched

How can I tell the playbook from the action, which host to target?

Michael.

Ideally Payload Data should contain HOSTNAME of the Router. Recently we have implemented many projects for different scenarios, here is my understanding and experience.

If event source that triggers events does not contain any data related to the hostname for the playbook to execute on, the playbook runs on all inventory hosts, as it is written to run on all hosts, as shown below