if empty, password is generated
This commit is contained in:
@@ -17,9 +17,13 @@ bindpwd - from group variables
|
||||
file : default account.csv csv file containing user to create:
|
||||
|
||||
```csv
|
||||
org,firstname,lastname,email,password
|
||||
org,firstname,lastname,email,[password]
|
||||
```
|
||||
|
||||
password field optionnal - if empty will be generated automatically - WIP
|
||||
|
||||
keep the final comma, though !
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
---
|
||||
- name: add ldap ou
|
||||
community.general.ldap_entry:
|
||||
dn: "ou={{ org }},{{ ldap_base }}"
|
||||
bind_dn: "{{ binddn }}"
|
||||
bind_pw: "{{ bindpwd }}"
|
||||
objectClass:
|
||||
- organizationalUnit
|
||||
- top
|
||||
|
||||
- name: add ldap account
|
||||
vars:
|
||||
- name: set vars
|
||||
ansible.builtin.set_fact:
|
||||
firstname: "{{ item.firstname }}"
|
||||
lastname: "{{ item.lastname }}"
|
||||
email: "{{ item.email }}"
|
||||
password: "{{ (item.password=='')| ternary(lookup('community.general.random_string', min_lower=1, min_upper=1, min_special=1, min_numeric=1, length=14), item.password ) }}"
|
||||
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 {{ item.firstname }}"
|
||||
community.general.ldap_entry:
|
||||
bind_dn: "{{ binddn }}"
|
||||
bind_pw: "{{ bindpwd }}"
|
||||
@@ -31,3 +24,9 @@
|
||||
PreferredDeliveryMethod: any
|
||||
displayName: "{{ firstname }} {{ lastname }}"
|
||||
userPassword: "{{ password }}"
|
||||
register: result
|
||||
|
||||
- name: display
|
||||
debug:
|
||||
msg: "{{ firstname }} created with password >{{ password }}<"
|
||||
when: result.changed
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
tags: always
|
||||
when: binddn is not defined
|
||||
|
||||
- name: add ldap ou
|
||||
community.general.ldap_entry:
|
||||
dn: "ou={{ org }},{{ ldap_base }}"
|
||||
bind_dn: "{{ binddn }}"
|
||||
bind_pw: "{{ bindpwd }}"
|
||||
objectClass:
|
||||
- organizationalUnit
|
||||
- top
|
||||
|
||||
- name: read csv file
|
||||
community.general.read_csv:
|
||||
path: '{{ file|default( "account.csv" ) }}'
|
||||
@@ -18,3 +27,4 @@
|
||||
loop: "{{ users.list }}"
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user