mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-29 19:04:42 +00:00
ipauser: Return generated random password
The random password is only returned if random is yes and user did not exist
or update_password is yes.
If only one user is handled by the module, the returned dict is containing
this dict:
{ "randompassword": "<the user random password>" }
If several users are handled by the module:
{ "<user>": { "randompassword": "<the user random password>" } }
This is related to issue #134 (ipahost does not return the random password)
This commit is contained in:
70
tests/user/test_user_random.yml
Normal file
70
tests/user/test_user_random.yml
Normal file
@@ -0,0 +1,70 @@
|
||||
---
|
||||
- name: Test ipauser random password generation
|
||||
hosts: ipaserver
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Users user1 and user2 absent
|
||||
ipauser:
|
||||
ipaadmin_password: MyPassword123
|
||||
name:
|
||||
- user1
|
||||
- user2
|
||||
state: absent
|
||||
|
||||
- name: User user1 present with random password
|
||||
ipauser:
|
||||
ipaadmin_password: MyPassword123
|
||||
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
|
||||
|
||||
- name: Print generated random password
|
||||
debug:
|
||||
var: ipauser.user.randompassword
|
||||
|
||||
- name: User user1 absent
|
||||
ipauser:
|
||||
ipaadmin_password: MyPassword123
|
||||
name:
|
||||
- user1
|
||||
state: absent
|
||||
|
||||
- name: Users user1 and user1 present with random password
|
||||
ipauser:
|
||||
ipaadmin_password: MyPassword123
|
||||
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
|
||||
|
||||
- name: Print generated random password for user1
|
||||
debug:
|
||||
var: ipauser.user.user1.randompassword
|
||||
|
||||
- name: Print generated random password for user2
|
||||
debug:
|
||||
var: ipauser.user.user2.randompassword
|
||||
|
||||
- name: Users user1 and user2 absent
|
||||
ipauser:
|
||||
ipaadmin_password: MyPassword123
|
||||
name:
|
||||
- user1
|
||||
- user2
|
||||
state: absent
|
||||
Reference in New Issue
Block a user