Closed khouloudfr closed 3 months ago
Hello, I want to create a list of users with a randomly generated password to store in a file. I have this code generating the password for all my users in the list but the problem is that I get one password only for all users.
this is my configuration:
tasks/add-user.yml
tasks/main.yml config:
name: users list include_vars: file: "files/users.yml"
name: Set user passwords set_fact: user_password: "{{ lookup('ansible.builtin.password', 'credential/' + user_name +'/password.txt', length=15) }}" loop: "{{ list }}"
include_tasks: add-user.yml when: user_action == "add"
include_tasks: delete-user.yml when: user_action == "delete"
files/users.yml
list:
user_name: user3 privilege: "Administrator"
Any guidance would be greatly appreciated.
Thank you
Hello, I want to create a list of users with a randomly generated password to store in a file. I have this code generating the password for all my users in the list but the problem is that I get one password only for all users.
this is my configuration:
tasks/add-user.yml
tasks/main.yml config:
name: users list include_vars: file: "files/users.yml"
name: Set user passwords set_fact: user_password: "{{ lookup('ansible.builtin.password', 'credential/' + user_name +'/password.txt', length=15) }}" loop: "{{ list }}"
include_tasks: add-user.yml when: user_action == "add"
include_tasks: delete-user.yml when: user_action == "delete"
files/users.yml
list:
user_name: user3 privilege: "Administrator"
Any guidance would be greatly appreciated.
Thank you