From 41d5b9314b3f7ad2abbb075af368ac1d3f4d32dd Mon Sep 17 00:00:00 2001 From: "tompage1994@hotmail.co.uk" Date: Wed, 17 Apr 2024 13:55:32 +0100 Subject: [PATCH] Fixed an issue where if version was not specified in ah_collection and state=absent then the module will fail --- changelogs/fragments/bug_collection_delete.yml | 4 ++++ plugins/modules/ah_collection.py | 2 +- tests/playbooks/ah_configs/ah_collections.yml | 5 +++++ tests/playbooks/testing_collections_playbook.yml | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/bug_collection_delete.yml diff --git a/changelogs/fragments/bug_collection_delete.yml b/changelogs/fragments/bug_collection_delete.yml new file mode 100644 index 00000000..4d4bf5f8 --- /dev/null +++ b/changelogs/fragments/bug_collection_delete.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - Fixed an issue where if version was not specified in ah_collection and state=absent then the module will fail +... diff --git a/plugins/modules/ah_collection.py b/plugins/modules/ah_collection.py index 96231bbb..1fdc6772 100644 --- a/plugins/modules/ah_collection.py +++ b/plugins/modules/ah_collection.py @@ -142,7 +142,7 @@ def main(): if auto_approve: if version: pass - else: + elif path: version = path.split("-")[-1].replace('.tar.gz', '') # Attempt to look up an existing item based on the provided data diff --git a/tests/playbooks/ah_configs/ah_collections.yml b/tests/playbooks/ah_configs/ah_collections.yml index 067a71f8..50493cf3 100644 --- a/tests/playbooks/ah_configs/ah_collections.yml +++ b/tests/playbooks/ah_configs/ah_collections.yml @@ -18,6 +18,11 @@ ah_collections_overwrite: timeout: 180 overwrite_existing: true +ah_collections_delete: + - namespace: galaxy + name: galaxy + state: absent + ah_git_collections: - collection_name: collection_test git_url: https://github.com/sean-m-sullivan/collection_test diff --git a/tests/playbooks/testing_collections_playbook.yml b/tests/playbooks/testing_collections_playbook.yml index 578d5292..0e1616ed 100644 --- a/tests/playbooks/testing_collections_playbook.yml +++ b/tests/playbooks/testing_collections_playbook.yml @@ -62,6 +62,12 @@ vars: ah_collections: "{{ ah_collections_overwrite }}" + - name: Delete Collection + ansible.builtin.include_role: + name: collection + vars: + ah_collections: "{{ ah_collections_delete }}" + - name: Publish Collections ansible.builtin.include_role: name: publish