2024-10-16 15:53:15 +00:00
|
|
|
- name: Generate a random root password
|
|
|
|
set_fact:
|
|
|
|
root_password: "{{ lookup('password', '/dev/null length=18 chars=ascii_letters,digits') }}"
|
|
|
|
- name: Save root password into Passbolt
|
|
|
|
set_fact:
|
|
|
|
msg: >
|
|
|
|
{{
|
|
|
|
lookup(passbolt, inventory_hostname_short,
|
|
|
|
username='root',
|
|
|
|
password=root_password,
|
|
|
|
uri='ssh://'+hostname_fqdn
|
|
|
|
)
|
|
|
|
}}
|
|
|
|
environment:
|
|
|
|
PASSBOLT_CREATE_NEW_RESOURCE: true
|
2024-10-17 11:18:45 +00:00
|
|
|
when: vn_witness
|
2024-10-16 15:53:15 +00:00
|
|
|
- name: Save the root password to file
|
|
|
|
copy:
|
|
|
|
content: "{{ root_password }}\n"
|
|
|
|
dest: /root/root_password.txt
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '0600'
|
2024-10-17 11:18:45 +00:00
|
|
|
when: vn_witness
|
|
|
|
register: local
|
2024-10-16 15:53:15 +00:00
|
|
|
- name: Change root password
|
|
|
|
user:
|
|
|
|
name: root
|
|
|
|
password: "{{ root_password | password_hash('sha512') }}"
|
2024-10-17 11:18:45 +00:00
|
|
|
when: local.changed
|