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
This commit is contained in:
Dmitriy Rabotyagov 2020-11-16 10:35:20 +02:00
parent 8b98452cbb
commit 8b35c64fda
1 changed files with 4 additions and 1 deletions

View File

@ -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)