diff --git a/plugins/modules/activation.py b/plugins/modules/activation.py index 472729e9..55aa0945 100644 --- a/plugins/modules/activation.py +++ b/plugins/modules/activation.py @@ -91,13 +91,6 @@ - This parameter is supported in AAP 2.5 and onwards. If specified for AAP 2.4, value will be ignored. type: str - webhooks: - description: - - A list of webhook IDs associated with the rulebook activation. - - This parameter is supported in AAP 2.5 and onwards. - If specified for AAP 2.4, value will be ignored. - type: list - elements: str swap_single_source: description: - Allow swapping of single sources in a rulebook without name match. @@ -260,16 +253,16 @@ def create_params( if not is_aap_24 and module.params.get("k8s_service_name"): activation_params["k8s_service_name"] = module.params["k8s_service_name"] - # Get the webhook ids - webhooks_ids = None - if not is_aap_24 and module.params.get("webhooks"): - webhooks_ids = [] - for item in module.params["webhooks"]: - webhook_id = lookup_resource_id(module, controller, "webhooks", item) - if webhook_id is not None: - webhooks_ids.append(webhook_id) - if webhooks_ids is not None: - activation_params["webhooks"] = webhooks_ids + # Get the event stream ids + event_stream_ids = None + if not is_aap_24 and module.params.get("event-streams"): + event_stream_ids = [] + for item in module.params["event_streams"]: + event_stream_id = lookup_resource_id(module, controller, "event-streams", item) + if event_stream_id is not None: + event_stream_ids.append(event_stream_id) + if event_stream_ids is not None: + activation_params["event_streams"] = event_stream_ids if not is_aap_24 and module.params.get("log_level"): activation_params["log_level"] = module.params["log_level"] @@ -300,10 +293,9 @@ def main() -> None: decision_environment_name=dict(type="str", aliases=["decision_environment"]), awx_token_name=dict(type="str", aliases=["awx_token", "token"]), organization_name=dict(type="str", aliases=["organization"]), - event_streams=dict(type="list", elements="int"), eda_credentials=dict(type="list", elements="str", aliases=["credentials"]), k8s_service_name=dict(type="str"), - webhooks=dict(type="list", elements="str"), + event_streams=dict(type="list", elements="str"), swap_single_source=dict(type="bool", default=True), log_level=dict(type="str", choices=["debug", "info", "error"], default="debug"), state=dict(choices=["present", "absent"], default="present"), diff --git a/plugins/modules/activation_info.py b/plugins/modules/activation_info.py index d440dd0d..2300c69d 100644 --- a/plugins/modules/activation_info.py +++ b/plugins/modules/activation_info.py @@ -67,11 +67,10 @@ "modified_at": "2024-08-15T11:45:00.987Z", "status_message": "Activation is running successfully.", "awx_token_id": 1, - "event_streams": [], "log_level": "info", "eda_credentials": [], "k8s_service_name": "", - "webhooks": [], + "event_streams": [], "swap_single_source": false } ] diff --git a/tests/integration/targets/activation/tasks/main.yml b/tests/integration/targets/activation/tasks/main.yml index cc68c315..5c408122 100644 --- a/tests/integration/targets/activation/tasks/main.yml +++ b/tests/integration/targets/activation/tasks/main.yml @@ -29,6 +29,8 @@ image_url: "quay.io/ansible/awx:latest" scm_url: https://github.com/ansible/event-driven-ansible.git rulebook_name: "demo_controller_rulebook.yml" + event_stream_name: "Test_EvenStream_{{ test_id }}" + credential_name_basic: "Test_CredentialBasic_{{ test_id }}" - name: Create an AWX controller token ansible.eda.controller_token: @@ -189,6 +191,51 @@ - name: List all the rulebook activations ansible.eda.activation_info: + - name: Delete rulebook activation + ansible.eda.activation: + name: "{{ activation_name }}" + state: absent + + # Test event_streams option + - name: Create a new credential + ansible.eda.credential: + state: present + name: "{{ credential_name_basic }}" + description: "This is a test credential" + credential_type_name: "Basic Event Stream" + inputs: + username: "test" + password: "test" + organization_name: Default + register: _result + + - name: Create an event stream + ansible.eda.event_stream: + state: present + name: "{{ event_stream_name }}" + credential_name: "{{ credential_name_basic }}" + organization_name: Default + register: _result + + - name: Create a rulebook activation + ansible.eda.activation: + name: "{{ activation_name }}" + description: "Example Activation description" + project_name: "{{ project_name }}" + rulebook_name: "{{ rulebook_name }}" + decision_environment_name: "{{ decision_env_name }}" + enabled: False + awx_token_name: "{{ awx_token_name }}" + organization_name: Default + event_streams: + - "{{ event_stream_name }}" + register: _result + + - name: Check rulebook activation creation + assert: + that: + - _result.changed + - name: Delete project ansible.eda.project: name: "{{ project_name }}" @@ -213,11 +260,6 @@ - credential_deletion is changed - credential_deletion is success - - name: Delete rulebook activation - ansible.eda.activation: - name: "{{ activation_name }}" - state: absent - always: - name: Delete AWX token ansible.eda.controller_token: @@ -231,18 +273,6 @@ state: absent ignore_errors: true - - name: Delete credential - ansible.eda.credential: - name: "{{ credential_name }}" - state: absent - ignore_errors: true - - - name: Delete credential type - ansible.eda.credential_type: - name: "{{ credential_type_name }}" - state: absent - ignore_errors: true - - name: Delete rulebook activation ansible.eda.activation: name: "{{ activation_name }}" @@ -254,3 +284,24 @@ name: "{{ decision_env_name }}" state: absent ignore_errors: true + + - name: Delete event stream + ansible.eda.event_stream: + name: "{{ event_stream_name }}" + state: absent + ignore_errors: true + + - name: Delete credentials + ansible.eda.credential: + name: "{{ item }}" + state: absent + loop: + - "{{ credential_name }}" + - "{{ credential_name_basic }}" + ignore_errors: true + + - name: Delete credential type + ansible.eda.credential_type: + name: "{{ credential_type_name }}" + state: absent + ignore_errors: true