1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Ensured `changed returns False`. (#1530)

* Ensured ``changed`` returns ``False``.

- Added small improvement on the ``_load_scope()`` method.

* yamllint caught it

* Rephrased changelog fragment
This commit is contained in:
Alexei Znamensky 2020-12-23 03:56:46 +13:00 committed by GitHub
parent 50aead4636
commit 1faf8ef08b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 13 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- ldap_search - the module no longer incorrectly reports a change (https://github.com/ansible-collections/community.general/issues/1040).

View file

@ -112,7 +112,7 @@ def main():
except Exception as exception:
module.fail_json(msg="Attribute action failed.", details=to_native(exception))
module.exit_json(changed=True)
module.exit_json(changed=False)
def _extract_entry(dn, attrs):
@ -144,24 +144,20 @@ class LdapSearch(LdapGeneric):
self.attrsonly = 0
def _load_scope(self):
scope = self.module.params['scope']
if scope == 'base':
self.scope = ldap.SCOPE_BASE
elif scope == 'onelevel':
self.scope = ldap.SCOPE_ONELEVEL
elif scope == 'subordinate':
self.scope = ldap.SCOPE_SUBORDINATE
elif scope == 'children':
self.scope = ldap.SCOPE_SUBTREE
else:
raise AssertionError('Implementation error')
spec = dict(
base=ldap.SCOPE_BASE,
onelevel=ldap.SCOPE_ONELEVEL,
subordinate=ldap.SCOPE_SUBORDINATE,
children=ldap.SCOPE_SUBTREE,
)
self.scope = spec[self.module.params['scope']]
def _load_attrs(self):
self.attrlist = self.module.params['attrs'] or None
def main(self):
results = self.perform_search()
self.module.exit_json(changed=True, results=results)
self.module.exit_json(changed=False, results=results)
def perform_search(self):
try: