Merge pull request #148 from t-woerner/return_random_passwords

ipauser, ipahost: Return random password
This commit is contained in:
Varun Mylaraiah
2019-11-21 11:57:01 +05:30
committed by GitHub
9 changed files with 333 additions and 7 deletions

View File

@@ -0,0 +1,41 @@
---
- name: Test ipahost random password generation
hosts: ipaserver
become: true
tasks:
- name: Get Domain from server name
set_fact:
ipaserver_domain: "{{ groups.ipaserver[0].split('.')[1:] | join ('.') }}"
when: ipaserver_domain is not defined
- name: Test hosts absent
ipahost:
ipaadmin_password: MyPassword123
name:
- "{{ 'host1.' + ipaserver_domain }}"
- "{{ 'host2.' + ipaserver_domain }}"
update_dns: yes
state: absent
- name: Host "{{ 'host1.' + ipaserver_domain }}" present with random password
ipahost:
ipaadmin_password: MyPassword123
name: "{{ 'host1.' + ipaserver_domain }}"
random: yes
force: yes
update_password: on_create
register: ipahost
failed_when: not ipahost.changed or
ipahost.host.randompassword is not defined
- name: Print generated random password
debug:
var: ipahost.host.randompassword
- name: Host "{{ 'host1.' + ipaserver_domain }}" absent
ipahost:
ipaadmin_password: MyPassword123
name:
- "{{ 'host1.' + ipaserver_domain }}"
state: absent

View 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