Closed Petraea closed 6 years ago
Adding such flattenning would be an incompatible change. This is now supported instead using an explicit "terms:" parameter accepting a list of terms. In your example this would be:
with_ldap:
- context: my_ctx
- terms: "{{ users }}"
Hi there,
There's a mild oversight in this plugin. If you want to pass in a list of terms from e.g. a variable, then you'd do so like so:
vars: users:
userb ldap_lookup_config: url: ldaps://myldap base: DC=my,DC=site binddn: "abind@mysite" bindpw: "apwd" my_ctx: base: DC=my,DC=site key: term value: mail filter: (cn={{ term }})
However, without this PR the ldap function will simply flatten the users list into a string, and attempt to lookup like so:
LDAP search, expanded: {u'binddn': u'abind@mysite', 'context': {u'binddn': u'abind@mysite', u'key': u'cn', u'url': u'ldaps://myldap', u'value': u'mail', u'filter': u"(cn=[u'usera', u'userb'])", u'base': u'DC=my,DC=site', u'bindpw': u'apwd', 'context': {u'url': u'ldaps://myldap', u'binddn': u'abind@mysite', u'base': u'DC=my,DC=site', u'bindpw': u'apwd'}}, u'url': u'ldaps://myldap', u'value': u'mail', 'filter': u"(cn=[u'usera', u'userb'])", 'base': u'DC=my,DC=site', u'bindpw': u'apwd', 'wantlist': True, u'key': u'cn', 'scope': 'subtree'}
This PR pulls in any list terms into the main terms list, allowing full iteration.