[PR #8887/0bc5f248 backport][stable-8] one_service: fix recreation (#8931)

one_service: fix recreation (#8887)

* Fix one_service unique creation

* Revert empty space

* Add CHANGELOG fragment

* Update CHANGELOG fragment

(cherry picked from commit 0bc5f24863)

Co-authored-by: alexander <79072457+abakanovskii@users.noreply.github.com>
pull/8939/head
patchback[bot] 2024-09-26 11:38:30 +03:00 committed by GitHub
parent 1caee897b1
commit 18a8c6f350
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 2 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- one_service - fix service creation after it was deleted with ``unique`` parameter (https://github.com/ansible-collections/community.general/issues/3137, https://github.com/ansible-collections/community.general/pull/8887).

View File

@ -522,7 +522,7 @@ def create_service_and_operation(module, auth, template_id, service_name, owner_
if unique:
service = get_service_by_name(module, auth, service_name)
if not service:
if not service or service["TEMPLATE"]["BODY"]["state"] == "DONE":
if not module.check_mode:
service = create_service(module, auth, template_id, service_name, custom_attrs, unique, wait, wait_timeout)
changed = True
@ -637,7 +637,6 @@ def get_service_id_by_name(module, auth, service_name):
def get_connection_info(module):
url = module.params.get('api_url')
username = module.params.get('api_username')
password = module.params.get('api_password')