ansible / event-driven-ansible

Ansible Collection for EDA
https://ansible.readthedocs.io/projects/ansible-eda/
Apache License 2.0
280 stars 110 forks source link

Unable to create event stream for the correct event type #358

Open ecchong opened 1 week ago

ecchong commented 1 week ago

Please confirm the following

Bug Summary

Trying to create a event stream of Basic Event Stream type with a credential of Basic Event Stream credential type

  tasks:
    - name: TEST
      ansible.eda.event_stream:
        controller_host: https://aap25-gateway
        controller_username: admin
        controller_password: password
        validate_certs: false
        name: dummy
        credential_name: "ABC/basic event stream credential"
        organization_name: "ABC"
        forward_events: true

The create event stream is of type Hmac. Specifing the "event_stream_type" does not help, since it is ignored according to doc.

Environment

AAP 2.5

Steps to reproduce

Run playbook with task

  tasks:
    - name: TEST
      ansible.eda.event_stream:
        controller_host: https://aap25-gateway
        controller_username: admin
        controller_password: password
        validate_certs: false
        name: dummy
        credential_name: "ABC/basic event stream credential"
        organization_name: "ABC"
        forward_events: true

Actual results

Event stream created with "Hmac" type

Expected results

Event stream created with type of assigned event stream credential. In this case "Basic Event Stream"

Additional information

No response

Alex-Izquierdo commented 1 week ago

Hello @ecchong The type of the event stream is assigned by the backend based on the type of the credential used. The collection is not involved in that process, it seems more a bug of eda-server, not of the collection, to reproduce the issue we need to know also how the credential was created.

ecchong commented 1 week ago

Hmm. If I post to the EDA API directly with the same EDA credential, the event stream is created with the correct type. For example

  tasks:
    - ansible.builtin.uri:
        url: "https://aap25-gateway/api/eda/v1/event-streams/"
        method: POST
        validate_certs: false
        body_format: json
        body:
          name: "dummy"
          test_mode: false
          additional_data_headers: ""
          eda_credential_id: 8
          organization_id: 1
          event_stream_type: "Basic Event Stream"
        force_basic_auth: true
        user: admin
        password: password
        status_code:
          - 201
          - 400

I would expect the same problem if this is an error on the EDA backend. The EDA credential is created directly on the console with credential type "Basic Event Stream". What version of EDA backend are expecting to assign the type? May be we should not ignore "event_stream_type" parameter yet.

Alex-Izquierdo commented 1 week ago

It still might be an issue of the backend, the event_stream_type should not be passed. Anyway, I would still need all the steps to reproduce the issue, it means how the credential was created. If both, credential and event stream were created with a playbook, please can you provide it?

ecchong commented 1 week ago

For example, this playbook created the Basic Event Stream credential "dummy credential", but the event stream "dummy" is created with type "Hmac"

---
- hosts: localhost
  connection: local
  gather_facts: false

  vars:
    controller_host: https://aap25-gateway
    controller_username: admin
    controller_password: password

  tasks:
    - name: Create EDA event stream credentail
      ansible.eda.credential:
        controller_host: "{{ controller_host }}"
        controller_username: "{{ controller_username }}"
        controller_password: "{{ controller_password }}"
        validate_certs: false
        name: "dummy credential"
        description: This is a basic event stream credential
        inputs:
          username: foo
          password: bar
        credential_type_name: "Basic Event Stream"
        organization_name: Default

    - name: Create EDA event stream
      ansible.eda.event_stream:
        controller_host: "{{ controller_host }}"
        controller_username: "{{ controller_username }}"
        controller_password: "{{ controller_password }}"
        validate_certs: false
        name: dummy
        credential_name: "dummy credential"
        organization_name: Default
        forward_events: true
        type: basic
wzzrd commented 1 week ago

I see the same problem. Credential has type basic event stream, and is created correctly. Event stream created (ansible.eda.event_stream) has type hmac instead of basic event stream. Creating the event stream manually yields the correct result, with the collection, the even stream always ends up with type hmac