Files
ansible-freeipa/tests/user/test_user_random.yml
Thomas Woerner 61caa57801 ipauser: Make return value depending on users parameter
The way how randompasswords are returned by the ipauser module depends
so far on the number of users that are handled by the module.

This is unexpected if for example a json file is provided with the users
parameter. As it might be unknown how many users are in the json file,
this behaviour is unexpected. The return should not vary in this case.

This chamge makes the return simply depend on the use of the users
paramater. As soon as this parameter is used, the return will always be:

"user": { "<the user>": { "randompassword": "<the user random password>" } }

In the simply case with one user it will be still

"user": { "randompassword": "<the user random password>" }

Fixes: #1052 (ipauser should consitently return randompasswords when
              used with users)
2023-03-02 11:42:32 +01:00

94 lines
2.3 KiB
YAML

---
- name: Test ipauser random password generation
hosts: ipaserver
become: true
tasks:
- name: Users user1 and user2 absent
ipauser:
ipaadmin_password: SomeADMINpassword
name:
- user1
- user2
state: absent
- name: User user1 present with random password
ipauser:
ipaadmin_password: SomeADMINpassword
name: user1
first: first1
last: last1
random: yes
update_password: on_create
register: ipauser
failed_when: not ipauser.changed or
ipauser.user.randompassword is not defined or
ipauser.failed
- name: Print generated random password
ansible.builtin.debug:
var: ipauser.user.randompassword
- name: User user1 absent
ipauser:
ipaadmin_password: SomeADMINpassword
name:
- user1
state: absent
- name: User user1 is present with random password using users parameter
ipauser:
ipaadmin_password: SomeADMINpassword
users:
- name: user1
first: first1
last: last1
random: yes
update_password: on_create
register: ipauser
failed_when: not ipauser.changed or
ipauser.user.user1.randompassword is not defined or
ipauser.failed
- name: User user1 absent
ipauser:
ipaadmin_password: SomeADMINpassword
name:
- user1
state: absent
- name: Users user1 and user2 present with random password
ipauser:
ipaadmin_password: SomeADMINpassword
users:
- name: user1
first: first1
last: last1
random: yes
- name: user2
first: first2
last: last2
random: yes
update_password: on_create
register: ipauser
failed_when: not ipauser.changed or
ipauser.user.user1.randompassword is not defined or
ipauser.user.user2.randompassword is not defined or
ipauser.failed
- name: Print generated random password for user1
ansible.builtin.debug:
var: ipauser.user.user1.randompassword
- name: Print generated random password for user2
ansible.builtin.debug:
var: ipauser.user.user2.randompassword
- name: Users user1 and user2 absent
ipauser:
ipaadmin_password: SomeADMINpassword
name:
- user1
- user2
state: absent