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

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

Open
3 tasks done
ecchong opened this issue Nov 19, 2024 · 6 comments
Open
3 tasks done

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

ecchong opened this issue Nov 19, 2024 · 6 comments

Comments

@ecchong
Copy link

ecchong commented Nov 19, 2024

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that event-driven-ansible collection is open source software provided for free and that I might not receive a timely response.

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
Copy link
Contributor

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
Copy link
Author

ecchong commented Nov 19, 2024

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
Copy link
Contributor

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
Copy link
Author

ecchong commented Nov 20, 2024

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
Copy link

wzzrd commented Nov 22, 2024

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

@Alex-Izquierdo
Copy link
Contributor

Hello @wzzrd @ecchong I can not reproduce the problem with the latest stream of eda collection and eda server.
As a tip, I want to remind that no type needs to be defined for the event stream, since the backend determines it automatically based on the type of the credential. A example playbook looks like this one:

- hosts: localhost
  connection: local
  gather_facts: no
  vars:
    # Development environment defaults
    controller_host: https://localhost:8443
    controller_username: admin
    controller_password: testpass
    validate_certs: no
  module_defaults:
    group/ansible.eda.eda:
      controller_host: "{{ controller_host }}"
      controller_username: "{{ controller_username }}"
      controller_password: "{{ controller_password }}"
      validate_certs: "{{ validate_certs }}"
  tasks:
    - name: Create EDA event stream credentail
      ansible.eda.credential:
        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:
        name: dummy
        credential_name: "dummy credential"
        organization_name: Default
        forward_events: true

Looking at your example I believe you are working with a commercial subscription of Ansible Automation Platform and very probably the next upgrade will include the version fixed.
We don't provide support for commercial subscriptions in this project, if you have any question please contact with Red Hat Support.

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

3 participants