Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Kafka Message Key in Events #114

Open
butschi84 opened this issue Apr 18, 2023 · 0 comments
Open

Include Kafka Message Key in Events #114

butschi84 opened this issue Apr 18, 2023 · 0 comments

Comments

@butschi84
Copy link

I suggest to include the "message key" (from the events in the kafka message queue) in the event that is being put into the event-driven-ansible queue because it can be very useful when filtering for certain events in an ansible-rulebook.

Therefore this file would have to be changed:
extensions/eda/plugins/event_sources/kafka.py
to something like:

 async for msg in kafka_consumer:
            try:
                data = json.loads(msg.value)
                data["key"] = msg.key.decode('utf-8')
                await queue.put(data)
...

After this change i can listen for events with certain key in the rulebook:

- name: listen kafka
  hosts: all
  sources:
    - ansible.eda.kafka:
        host: 7.7.7.7
        port: 30051
        topic: my-topic
        group_id: ansible-eda
  rules:
    - name: kafka
      condition: event.key == "test-0"
      action:
        run_playbook:
          name: do-something.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant