summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-12-08 19:39:01 +0100
committerGuilhem Moulin <guilhem@fripost.org>2016-12-08 19:39:01 +0100
commitca71056ec50e7b51ca0eaebb7a716207ce1a00e6 (patch)
tree3d782f3ad97db1095765db8c5fe137bb1eb34069 /lib
parent43f39850ffd9e658b4d783106ea32d9f5430e633 (diff)
Make Ansible modules compatible with Ansible 2.2.0.0.
Diffstat (limited to 'lib')
-rw-r--r--lib/action_plugins/openldap.py5
-rw-r--r--lib/modules/openldap14
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/action_plugins/openldap.py b/lib/action_plugins/openldap.py
index ad77abc..86ca41f 100644
--- a/lib/action_plugins/openldap.py
+++ b/lib/action_plugins/openldap.py
@@ -15,7 +15,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from ansible.plugins.action import ActionBase
-from ansible.utils.unicode import to_bytes, to_unicode
+from ansible.utils.unicode import to_bytes
+from ansible.module_utils._text import to_text
class ActionModule(ActionBase):
TRANSFERS_FILES = True
@@ -56,7 +57,7 @@ class ActionModule(ActionBase):
# template the source data locally
try:
with open(target, 'r') as f:
- template_data = to_unicode(f.read())
+ template_data = to_text(f.read())
target = self._templar.template(template_data, preserve_trailing_newlines=True, escape_backslashes=False, convert_data=False)
except Exception as e:
result['failed'] = True
diff --git a/lib/modules/openldap b/lib/modules/openldap
index 5178033..9b015b6 100644
--- a/lib/modules/openldap
+++ b/lib/modules/openldap
@@ -139,7 +139,7 @@ def processEntry(module, l, dn, entry):
for x in indexedAttributes.intersection(entry.keys()):
# remove useless extra spaces in ACLs etc
- entry[x] = map( partial(multispaces.sub, ' '), entry[x] )
+ entry[x] = list(map( partial(multispaces.sub, ' '), entry[x] ))
r = flexibleSearch( module, l, dn, entry )
if r is None:
@@ -149,8 +149,8 @@ def processEntry(module, l, dn, entry):
if 'olcAccess' in entry.keys():
# replace "username=...,cn=peercred,cn=external,cn=auth"
# by a DN with proper gidNumber and uidNumber
- entry['olcAccess'] = map ( partial(sasl_ext_re.sub, acl_sasl_ext)
- , entry['olcAccess'] )
+ entry['olcAccess'] = list(map ( partial(sasl_ext_re.sub, acl_sasl_ext)
+ , entry['olcAccess'] ))
l.add_s( dn, addModlist(entry) )
else:
d,e = r
@@ -166,11 +166,11 @@ def processEntry(module, l, dn, entry):
if a == 'olcAccess':
# replace "username=...,cn=peercred,cn=external,cn=auth"
# by a DN with proper gidNumber and uidNumber
- entry[a] = map ( partial(sasl_ext_re.sub, acl_sasl_ext)
- , entry[a] )
+ entry[a] = list(map ( partial(sasl_ext_re.sub, acl_sasl_ext)
+ , entry[a] ))
# add explicit indices in the entry from the LDIF
- entry[a] = map( (lambda x: '{%d}%s' % x)
- , zip(range(len(entry[a])),entry[a]) )
+ entry[a] = list(map( (lambda x: '{%d}%s' % x)
+ , zip(range(len(entry[a])),entry[a])))
if v != entry[a]:
diff.append(( ldap.MOD_REPLACE, a, entry[a] ))
elif v != entry[a]: