From 8b35c64fdac1b46bc10ae4b489914df7298944ab Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Mon, 16 Nov 2020 10:35:20 +0200 Subject: [PATCH] Do not fail when endpoint state is absent In case endpoint state is absent we shouldn't fail in case service does not exist, since it means that we're ok, and endpoint is not present. This might be pretty useful, when user tries to create and delete service and endpoint with the same code ie [1] [1] https://opendev.org/openstack/openstack-ansible-tests/src/branch/master/sync/tasks/service_setup.yml Change-Id: If7ecd7b2e28c81ffe18539731edd4efa599c42ec Closes-Bug: #1904029 --- plugins/modules/endpoint.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/modules/endpoint.py b/plugins/modules/endpoint.py index 6cd4d446..a570dc76 100644 --- a/plugins/modules/endpoint.py +++ b/plugins/modules/endpoint.py @@ -156,7 +156,10 @@ def main(): try: service = cloud.get_service(service_name_or_id) - if service is None: + if service is None and state == 'absent': + module.exit_json(changed=False) + + elif service is None and state == 'present': module.fail_json(msg='Service %s does not exist' % service_name_or_id) filters = dict(service_id=service.id, interface=interface)