output generated passwords to file

This commit is contained in:
agatha 2025-04-26 13:29:24 -04:00
parent 089ce9b396
commit d84c6ba00a

View File

@ -8,13 +8,19 @@
connection: local connection: local
gather_facts: false gather_facts: false
tasks: tasks:
- name: Display all generated passwords - name: Prepare password information
debug: set_fact:
msg: | password_info: |
Generated Passwords: Generated Passwords:
{% for host in groups['all'] %} {% for host in groups['all'] %}
{% if hostvars[host]['generated_password'] is defined %} {% if hostvars[host]['generated_password'] is defined %}
Host: {{ host }} Host: {{ host }}
Password: {{ hostvars[host]['generated_password'] }} Password: {{ hostvars[host]['generated_password'] }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
- name: Write password information to file
copy:
content: "{{ password_info }}"
dest: "../generated_passwords.txt"