From 098db6577470705a98205bd2613ca29f5319f21e Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Mon, 22 Apr 2024 11:27:11 +0200 Subject: [PATCH] org not needed in account.csv wip : create tmp password recap file upon account creation --- README.md | 15 +++------------ account.csv | 2 -- nlu.yml | 9 --------- tasks/ldap_user_inc.yml | 11 ++++++++--- tasks/main.yml | 2 +- 5 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 account.csv delete mode 100644 nlu.yml diff --git a/README.md b/README.md index 5d9ca80..a8baadc 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,10 @@ bindpwd - from group variables file : default account.csv csv file containing user to create: ```csv -org,firstname,lastname,email,[password] +firstname,lastname,email,[password] ``` -password field optionnal - if empty will be generated automatically +password field optionnal - if empty will be generated automatically - WIP keep the final comma, though ! @@ -34,20 +34,11 @@ Example Playbook Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: -```bash -cat < account.csv -org,firstname,lastname,email,password -plop,thom,foobar,thom@plope.fr, -EOF -``` - - hosts: collidine user: tom become: false roles: - - role: tco.new_ldap_user, - org: plop.fr - file: ~/Document/Opendoor/Clients/Plop/account.csv + - { role: tco.new_ldap_user, org=plop.fr,file: ~/Documents/Opendoor/Clients/Plop/account.csv } License ------- diff --git a/account.csv b/account.csv deleted file mode 100644 index 817e36d..0000000 --- a/account.csv +++ /dev/null @@ -1,2 +0,0 @@ -org,firstname,lastname,email,password -plop,thom,foobar,thom@plope.fr, diff --git a/nlu.yml b/nlu.yml deleted file mode 100644 index 8a1755b..0000000 --- a/nlu.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -- hosts: collidine - user: tom - become: false - roles: - - role: tco.new_ldap_user - org: plop.fr - file: account.csv - diff --git a/tasks/ldap_user_inc.yml b/tasks/ldap_user_inc.yml index 2cf28e6..10803d7 100644 --- a/tasks/ldap_user_inc.yml +++ b/tasks/ldap_user_inc.yml @@ -27,7 +27,12 @@ userPassword: "{{ password }}" register: result - - name: display - debug: - msg: "{{ firstname }} created with password >{{ password }}<" + - name: "account recap" + ansible.builtin.lineinfile: + path: "tmppassword.csv" + state: present + create: true + line: "{{ firstname | lower }},{{ password }}" + delegate_to: localhost + become: false when: result.changed diff --git a/tasks/main.yml b/tasks/main.yml index 683cb4b..e48074d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,7 +8,7 @@ tags: always when: binddn is not defined - - name: add ldap ou + - name: "add ldap ou ou={{ org }},{{ ldap_base }}" community.general.ldap_entry: dn: "ou={{ org }},{{ ldap_base }}" bind_dn: "{{ binddn }}"