--- - name: Setup base system hosts: all become: yes roles: - base_setup - hosts: localhost connection: local gather_facts: false tasks: - name: Prepare password information set_fact: password_info: | Generated Passwords: {% for host in groups['all'] %} {% if hostvars[host]['generated_password'] is defined %} Host: {{ host }} Password: {{ hostvars[host]['generated_password'] }} {% endif %} {% endfor %} - name: Write password information to file copy: content: "{{ password_info }}" dest: "../generated_passwords.txt"