diff --git a/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py b/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py index f57ce557b98..0b0e4b16d6d 100644 --- a/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py +++ b/lib/ansible/modules/remote_management/manageiq/manageiq_tenant.py @@ -35,7 +35,8 @@ version_added: '2.8' author: Evert Mulder (@evertmulder) description: - The manageiq_tenant module supports adding, updating and deleting tenants in ManageIQ. - +requirements: +- manageiq-client options: state: description: @@ -264,6 +265,9 @@ class ManageIQTenant(object): except Exception as e: self.module.fail_json(msg="failed to delete tenant %s: %s" % (tenant['name'], str(e))) + if result['success'] is False: + self.module.fail_json(msg=result['message']) + return dict(changed=True, msg=result['message']) def edit_tenant(self, tenant, name, description): @@ -513,9 +517,14 @@ def main(): res_args = manageiq_tenant.delete_tenant(tenant) # if we do not have a tenant, nothing to do else: + if parent_id: + msg = "tenant '%s' with parent_id %i does not exist in manageiq" % (name, parent_id) + else: + msg = "tenant '%s' with parent '%s' does not exist in manageiq" % (name, parent) + res_args = dict( changed=False, - msg="tenant %s: with parent: %i does not exist in manageiq" % (name, parent_id)) + msg=msg) # tenant should exist if state == "present":