From 739a129322cebf3abe54f1267518c81d99ef75ef Mon Sep 17 00:00:00 2001 From: Gustavo Muniz do Carmo Date: Fri, 12 Oct 2018 10:36:06 +0100 Subject: [PATCH] ldap_attr: typecast values to list (#46818) Adding a value to an attribute or removing a value from an attribute of a LDAP entry throws the exception TypeError: object of type 'filter' has no len() --- lib/ansible/modules/net_tools/ldap/ldap_attr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/net_tools/ldap/ldap_attr.py b/lib/ansible/modules/net_tools/ldap/ldap_attr.py index 320fd74595..f06ec24b1d 100644 --- a/lib/ansible/modules/net_tools/ldap/ldap_attr.py +++ b/lib/ansible/modules/net_tools/ldap/ldap_attr.py @@ -178,7 +178,7 @@ class LdapAttr(LdapGeneric): self.values = [to_bytes(self.module.params['values'])] def add(self): - values_to_add = filter(self._is_value_absent, self.values) + values_to_add = list(filter(self._is_value_absent, self.values)) if len(values_to_add) > 0: modlist = [(ldap.MOD_ADD, self.name, values_to_add)] @@ -188,7 +188,7 @@ class LdapAttr(LdapGeneric): return modlist def delete(self): - values_to_delete = filter(self._is_value_present, self.values) + values_to_delete = list(filter(self._is_value_present, self.values)) if len(values_to_delete) > 0: modlist = [(ldap.MOD_DELETE, self.name, values_to_delete)]