From 15fe4a5eb09d35be669737550f2341cff3617c41 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Mon, 13 May 2024 14:49:38 +0200 Subject: [PATCH] new variable so we can chose attribute used for DN --- README.md | 1 + defaults/main.yml | 1 + tasks/ldap_user_inc.yml | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a8baadc..cc06fa6 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Role Variables -------------- org: no default ldap_base - from group variables +nlu_dn_attribute - default firstname can be email binddn - from group variables bindpwd - from group variables file : default account.csv csv file containing user to create: diff --git a/defaults/main.yml b/defaults/main.yml index 56fa136..3389d1d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,3 @@ --- # defaults file for tco.new_ldap_user +nlu_dn_attribute: "firstname" diff --git a/tasks/ldap_user_inc.yml b/tasks/ldap_user_inc.yml index 10803d7..0e1ffe8 100644 --- a/tasks/ldap_user_inc.yml +++ b/tasks/ldap_user_inc.yml @@ -4,7 +4,7 @@ firstname: "{{ item.firstname }}" lastname: "{{ item.lastname }}" email: "{{ item.email }}" - dn: "uid={{ item.firstname |lower }}, ou={{ org }},{{ ldap_base }}" + dn: "uid={{ item[ nlu_dn_attribute ] |lower }},ou={{ org }},{{ ldap_base }}" password: "{{ (item.password=='')| ternary(lookup('community.general.random_string', min_lower=1, min_upper=1, special=false,min_numeric=1, length=14), item.password ) }}" - name: "add ldap account {{dn }}"