You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using infra.ah_configuration.ah_collection with state 'absent' as to delete collections from a repository appears not to be working. There are a couple of bugs present, and actual deletion does not happen.
ansible installation method: one of source, pip, OS package, EE
EE as part of Automation Platform
OS / ENVIRONMENT
Not applicable: management of Private Automation Hub via Ansible
Desired Behavior
Using the task:
- name: Delete all found collections from the repos
infra.ah_configuration.ah_collection:
ah_host: "{{ ah_url }}"
ah_token: "{{ ah_token }}"
namespace: "{{ this_collection.namespace }}"
name: "{{ this_collection.name }}"
state: absent
I want to delete a specific collection from the system.
Actual Behavior
First error that happens is stating:
ansible_collections/infra/ah_configuration/plugins/modules/ah_collection.py\", line 146, in main\r\nAttributeError: 'NoneType' object has no attribute 'split'\r\n
It turns out that the parameter 'auto_approve' is checked regardless of the parameter 'state'; by setting 'auto_approve' to 'false' I can work around this problem.
With the added 'auto_approve: false' the task will run, but it will either return 'ok' for some collections, or it will raise an exception for others. Output of the exception is:
Traceback (most recent call last):\r\n File \"/home/ansible/.ansible/tmp/ansible-tmp-1718827337.1524935-36-220491761771436/AnsiballZ_ah_collection.py\", line 107, in <module>\r\n _ansiballz_main()\r\n File \"/home/ansible/.ansible/tmp/ansible-tmp-1718827337.1524935-36-220491761771436/AnsiballZ_ah_collection.py\", line 99, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/ansible/.ansible/tmp/ansible-tmp-1718827337.1524935-36-220491761771436/AnsiballZ_ah_collection.py\", line 48, in invoke_module\r\n run_name='__main__', alter_sys=True)\r\n File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\r\n return _run_module_code(code, init_globals, run_name, mod_spec)\r\n File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\r\n mod_name, mod_spec, pkg_name, script_name)\r\n File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\r\n exec(code, run_globals)\r\n File \"/tmp/ansible_infra.ah_configuration.ah_collection_payload_lfzhbfyb/ansible_infra.ah_configuration.ah_collection_payload.zip/ansible_collections/infra/ah_configuration/plugins/modules/ah_collection.py\", line 227, in <module>\r\n File \"/tmp/ansible_infra.ah_configuration.ah_collection_payload_lfzhbfyb/ansible_infra.ah_configuration.ah_collection_payload.zip/ansible_collections/infra/ah_configuration/plugins/modules/ah_collection.py\", line 163, in main\r\nKeyError: 'task'\r\n"
It seems that this has to do with whether or not a collection has dependencies. However for the collections where the task returns 'ok', nothing is actually deleted.
STEPS TO REPRODUCE
Run the following playbook against a Private Automation Hub - fill in the hostname, username and password of the hub.
- name: Playbook to cleanup collections from Private Automation Hubhosts: hubgather_facts: falserun_once: truevars:
aap_platform_ah_username: "{{ uc_content_1 }}"aap_platform_ah_password: "{{ uc_content_2 }}"ah_collection_repos:
- communitytasks:
- name: Get an authentication token from the Hubinfra.ah_configuration.ah_token:
ah_host: "{{ ah_url }}"ah_username: "{{ lookup('file', aap_platform_ah_username) }}"ah_password: "{{ lookup('file', aap_platform_ah_password) }}"state: presentno_log: true
- name: Query the Automation Hub for all collections it knowsansible.builtin.set_fact:
ah_collections: | {{ ah_collections | default([]) + lookup('infra.ah_configuration.ah_api', 'collections', this_repo, host=ah_url, username=lookup('file', aap_platform_ah_username), password=lookup('file', aap_platform_ah_password), return_all=true) }}loop: "{{ ah_collection_repos }}"loop_control:
loop_var: this_repono_log: true
- name: Delete all found collections from the reposinfra.ah_configuration.ah_collection:
ah_host: "{{ ah_url }}"ah_token: "{{ ah_token }}"namespace: "{{ this_collection.namespace }}"name: "{{ this_collection.name }}"state: absentauto_approve: falseloop: "{{ ah_collections }}"loop_control:
loop_var: this_collection
- name: Delete this tokeninfra.ah_configuration.ah_token:
ah_host: "{{ ah_url }}"ah_token: "{{ ah_token }}"state: absent
The text was updated successfully, but these errors were encountered:
Summary
Using infra.ah_configuration.ah_collection with state 'absent' as to delete collections from a repository appears not to be working. There are a couple of bugs present, and actual deletion does not happen.
Issue Type
Ansible, Collection, Private Automation Hub details
EE as part of Automation Platform
OS / ENVIRONMENT
Not applicable: management of Private Automation Hub via Ansible
Desired Behavior
Using the task:
I want to delete a specific collection from the system.
Actual Behavior
First error that happens is stating:
It turns out that the parameter 'auto_approve' is checked regardless of the parameter 'state'; by setting 'auto_approve' to 'false' I can work around this problem.
With the added 'auto_approve: false' the task will run, but it will either return 'ok' for some collections, or it will raise an exception for others. Output of the exception is:
It seems that this has to do with whether or not a collection has dependencies. However for the collections where the task returns 'ok', nothing is actually deleted.
STEPS TO REPRODUCE
Run the following playbook against a Private Automation Hub - fill in the hostname, username and password of the hub.
The text was updated successfully, but these errors were encountered: