ansible / awx

AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is one of the upstream projects for Red Hat Ansible Automation Platform.
Other
14.08k stars 3.42k forks source link

Unable to specify empty value for webhook_credential (ansible.controller.job_template) #14843

Open kk-at-redhat opened 9 months ago

kk-at-redhat commented 9 months ago

Please confirm the following

Bug Summary

There is no way to specify empty webhook_credential for idempotency or to remove credential selection in that field. It should be accepting empty value and in this case also removing any credentials currently selected.

AWX version

23.2.0

Select the relevant components

Installation method

docker development environment

Modifications

no

Ansible version

2.14.2

Operating system

Red Hat Enterprise Linux release 9.1 (Plow)

Web browser

Chrome

Steps to reproduce

  tasks:
    - ansible.controller.export:
        job_templates: 'all'
      register: aap_templates

    - debug:
        var: aap_templates.assets.job_templates[0].webhook_credential

    - ansible.controller.job_template:
        name: "{{ aap_templates.assets.job_templates[0].name }}"
        webhook_credential: "{{ aap_templates.assets.job_templates[0].webhook_credential }}"
      ignore_errors: true

    - ansible.controller.job_template:
        name: "{{ aap_templates.assets.job_templates[0].name }}"
        webhook_credential: ""
      ignore_errors: true

    - ansible.controller.job_template:
        name: "{{ aap_templates.assets.job_templates[0].name }}"
        webhook_credential: {}
      ignore_errors: true

    - ansible.controller.job_template:
        name: "{{ aap_templates.assets.job_templates[0].name }}"
        webhook_credential: None
      ignore_errors: true

Expected results

TASK [ansible.controller.job_template] *********************************************************************************************************************
ok: [localhost]

Actual results

TASK [ansible.controller.export] ***************************************************************************************************************************
ok: [localhost]

TASK [debug] ***********************************************************************************************************************************************
ok: [localhost] => {
    "aap_templates.assets.job_templates[0].webhook_credential": ""
}

TASK [ansible.controller.job_template] *********************************************************************************************************************
[WARNING]: You are running collection version 4.5.0 but connecting to Red Hat Ansible Automation Platform version 4.3.4
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Request to /api/v2/credentials/ returned 20 items, expected 1", "query": null, "response": {"json": {"count": 20, "next": null, "previous": null, "results": [{"cloud": false, "created": "2024-01-02T22:07:12.298153Z", "credential_type": 1, "description": "", "id": 31, "inputs": {"become_method": "", "become_username": "", "password": "$encrypted$", "username": "ccc"}, "kind": "ssh", "kubernetes": false, "managed": false, "modified": "2024-01-02T22:07:12.298168Z", "name": "AAA", "organization": null, "related": {"access_list": "/api/v2/credentials/31/access_list/", "activity_stream": "/api/v2/credentials/31/activity_stream/", "copy": "/api/v2/credentials/31/copy/", "created_by": "/api/v2/users/1/", "credential_type": "/api/v2/credential_types/1/", "input_sources": "/api/v2/credentials/31/input_sources/", "modified_by": "/api/v2/users/1/", "object_roles": "/api/v2/credentials/31/object_roles/", "owner_teams": "/api/v2/credentials/31/owner_teams/", "owner_users": "/api/v2/credentials/31/owner_users/", "user": "/api/v2/users/1/"}, "summary_fields": {"created_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "credential_type": {"description": "", "id": 1, "name": "Machine"}, "modified_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "object_roles": {"admin_role": {"description": "Can manage all aspects of the credential", "id": 185, "name": "Admin"}, "read_role": {"description": "May view settings for the credential", "id": 187, "name": "Read"}, "use_role": {"description": "Can use the credential in a job template", "id": 186, "name": "Use"}}, "owners": [{"description": " ", "id": 1, "name": "admin", "type": "user", "url": "/api/v2/users/1/"}], "user_capabilities": {"copy": true, "delete": true, "edit": true, "use": true}}, "type": "credential", "url": "/api/v2/credentials/31/"}, {"cloud": false, "created": "2023-02-08T05:32:26.706064Z", "credential_type": 18, "description": "", "id": 2, "inputs": {"url": "https://galaxy.ansible.com/"}, "kind": "galaxy_api_token", "kubernetes": false, "managed": true, "modified": "2023-02-08T05:32:26.706075Z", "name": "Ansible Galaxy", "organization": null, "related": {"access_list": "/api/v2/credentials/2/access_list/", "activity_stream": "/api/v2/credentials/2/activity_stream/", "copy": "/api/v2/credentials/2/copy/", "created_by": "/api/v2/users/1/", "credential_type": "/api/v2/credential_types/18/", "input_sources": "/api/v2/credentials/2/input_sources/", "modified_by": "/api/v2/users/1/", "object_roles": "/api/v2/credentials/2/object_roles/", "owner_teams": "/api/v2/credentials/2/owner_teams/", "owner_users": "/api/v2/credentials/2/owner_users/"}, "summary_fields": {"created_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "credential_type": {"description": "", "id": 18, "name": "Ansible Galaxy/Automation Hub API Token"}, "modified_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "object_roles": {"admin_role": {"description": "Can manage all aspects of the credential", "id": 23, "name": "Admin"}, "read_role": {"description": "May view settings for the credential", "id": 25, "name": "Read"}, "use_role": {"description": "Can use the credential in a job template", "id": 24, "name": "Use"}}, "owners": [], "user_capabilities": {"copy": true, "delete": false, "edit": false, "use": true}}, "type": "credential", "url": "/api/v2/credentials/2/"}, "...more results snipped..."]}, "status_code": 200}, "total_results": 20}
...ignoring

TASK [ansible.controller.job_template] *********************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Request to /api/v2/credentials/ returned 20 items, expected 1", "query": null, "response": {"json": {"count": 20, "next": null, "previous": null, "results": [{"cloud": false, "created": "2024-01-02T22:07:12.298153Z", "credential_type": 1, "description": "", "id": 31, "inputs": {"become_method": "", "become_username": "", "password": "$encrypted$", "username": "ccc"}, "kind": "ssh", "kubernetes": false, "managed": false, "modified": "2024-01-02T22:07:12.298168Z", "name": "AAA", "organization": null, "related": {"access_list": "/api/v2/credentials/31/access_list/", "activity_stream": "/api/v2/credentials/31/activity_stream/", "copy": "/api/v2/credentials/31/copy/", "created_by": "/api/v2/users/1/", "credential_type": "/api/v2/credential_types/1/", "input_sources": "/api/v2/credentials/31/input_sources/", "modified_by": "/api/v2/users/1/", "object_roles": "/api/v2/credentials/31/object_roles/", "owner_teams": "/api/v2/credentials/31/owner_teams/", "owner_users": "/api/v2/credentials/31/owner_users/", "user": "/api/v2/users/1/"}, "summary_fields": {"created_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "credential_type": {"description": "", "id": 1, "name": "Machine"}, "modified_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "object_roles": {"admin_role": {"description": "Can manage all aspects of the credential", "id": 185, "name": "Admin"}, "read_role": {"description": "May view settings for the credential", "id": 187, "name": "Read"}, "use_role": {"description": "Can use the credential in a job template", "id": 186, "name": "Use"}}, "owners": [{"description": " ", "id": 1, "name": "admin", "type": "user", "url": "/api/v2/users/1/"}], "user_capabilities": {"copy": true, "delete": true, "edit": true, "use": true}}, "type": "credential", "url": "/api/v2/credentials/31/"}, {"cloud": false, "created": "2023-02-08T05:32:26.706064Z", "credential_type": 18, "description": "", "id": 2, "inputs": {"url": "https://galaxy.ansible.com/"}, "kind": "galaxy_api_token", "kubernetes": false, "managed": true, "modified": "2023-02-08T05:32:26.706075Z", "name": "Ansible Galaxy", "organization": null, "related": {"access_list": "/api/v2/credentials/2/access_list/", "activity_stream": "/api/v2/credentials/2/activity_stream/", "copy": "/api/v2/credentials/2/copy/", "created_by": "/api/v2/users/1/", "credential_type": "/api/v2/credential_types/18/", "input_sources": "/api/v2/credentials/2/input_sources/", "modified_by": "/api/v2/users/1/", "object_roles": "/api/v2/credentials/2/object_roles/", "owner_teams": "/api/v2/credentials/2/owner_teams/", "owner_users": "/api/v2/credentials/2/owner_users/"}, "summary_fields": {"created_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "credential_type": {"description": "", "id": 18, "name": "Ansible Galaxy/Automation Hub API Token"}, "modified_by": {"first_name": "", "id": 1, "last_name": "", "username": "admin"}, "object_roles": {"admin_role": {"description": "Can manage all aspects of the credential", "id": 23, "name": "Admin"}, "read_role": {"description": "May view settings for the credential", "id": 25, "name": "Read"}, "use_role": {"description": "Can use the credential in a job template", "id": 24, "name": "Use"}}, "owners": [], "user_capabilities": {"copy": true, "delete": false, "edit": false, "use": true}}, "type": "credential", "url": "/api/v2/credentials/2/"}, "...more results snipped..."]}, "status_code": 200}, "total_results": 20}
...ignoring

TASK [ansible.controller.job_template] *********************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Request to /api/v2/credentials/?name=%7B%7D returned 0 items, expected 1", "query": {"name": "{}"}, "response": {"json": {"count": 0, "next": null, "previous": null, "results": []}, "status_code": 200}, "total_results": 0}
...ignoring

TASK [ansible.controller.job_template] *********************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Request to /api/v2/credentials/?name=None returned 0 items, expected 1", "query": {"name": "None"}, "response": {"json": {"count": 0, "next": null, "previous": null, "results": []}, "status_code": 200}, "total_results": 0}
...ignoring

Additional information

No response

fosterseth commented 9 months ago

hard to tell from the output, which of those tasks are failing?