diff --git a/ci/roles/keystone_domain/tasks/main.yml b/ci/roles/keystone_domain/tasks/main.yml index 15f4c34d..73664dd7 100644 --- a/ci/roles/keystone_domain/tasks/main.yml +++ b/ci/roles/keystone_domain/tasks/main.yml @@ -1,19 +1,36 @@ --- - name: Create keystone domain openstack.cloud.identity_domain: - cloud: "{{ cloud }}" - state: present - name: "{{ domain_name }}" - description: "test description" + cloud: "{{ cloud }}" + state: present + name: "{{ domain_name }}" + description: "test description" + register: os_domain + +- name: Test output + assert: + that: + - "'domain' in os_domain" + - os_domain.domain.name == "{{ domain_name }}" + - >- + ('enabled' in os_domain.domain.keys() and os_domain.domain['enabled']|bool) or + ('is_enabled' in os_domain.domain and os_domain.domain['is_enabled']|bool) + - os_domain.domain.description == "test description" - name: Update keystone domain openstack.cloud.identity_domain: - cloud: "{{ cloud }}" - name: "{{ domain_name }}" - description: "updated description" + cloud: "{{ cloud }}" + name: "{{ domain_name }}" + description: "updated description" + register: os_domain_updated + +- name: Test output + assert: + that: + - os_domain_updated.domain.description == "updated description" - name: Delete keystone domain openstack.cloud.identity_domain: - cloud: "{{ cloud }}" - state: absent - name: "{{ domain_name }}" + cloud: "{{ cloud }}" + state: absent + name: "{{ domain_name }}" diff --git a/plugins/modules/identity_domain.py b/plugins/modules/identity_domain.py index 012a0916..660748c4 100644 --- a/plugins/modules/identity_domain.py +++ b/plugins/modules/identity_domain.py @@ -104,7 +104,8 @@ class IdentityDomainModule(OpenStackModule): if self.params['description'] is not None and \ domain.description != self.params['description']: return True - if domain.enabled != self.params['enabled']: + if domain.get( + "is_enabled", domain.get("enabled")) != self.params['enabled']: return True return False @@ -126,7 +127,7 @@ class IdentityDomainModule(OpenStackModule): enabled = self.params['enabled'] state = self.params['state'] - domains = self.conn.search_domains(filters=dict(name=name)) + domains = list(self.conn.identity.domains(name=name)) if len(domains) > 1: self.fail_json(msg='Domain name %s is not unique' % name) @@ -151,7 +152,10 @@ class IdentityDomainModule(OpenStackModule): changed = True else: changed = False - self.exit_json(changed=changed, domain=domain, id=domain.id) + if hasattr(domain, "to_dict"): + domain = domain.to_dict() + domain.pop("location") + self.exit_json(changed=changed, domain=domain, id=domain['id']) elif state == 'absent': if domain is None: