mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-28 10:24:47 +00:00
ipahost: Return generated random password
The random password is only returned if random is yes and the host did
not exist or update_password is yes.
If only one host is handled by the module, the returned dict is containing
this dict:
{ "randompassword": "<the host random password>" }
If several hosts are handled by the module (future feature):
{ "<host>": { "randompassword": "<the host random password>" } }
Fixes issue #134 (ipahost does not return the random password)
This commit is contained in:
41
tests/host/test_host_random.yml
Normal file
41
tests/host/test_host_random.yml
Normal 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
|
||||
Reference in New Issue
Block a user