Create the variable(s) *output*

    - set_fact:
        output: "{{ packages.results
                    |json_query('[].[name, version, release]')
                    |map('join','-') }}"

Then, use it(them) in the *content*

    - copy:
        dest: /tmp/installed.txt
        content: |
          {% for host in ansible_play_hosts %}
          {{ host }}:
          The following packages will be updated
          {{ hostvars[host]['output']|to_nice_yaml }}
          {% endfor %}
      run_once: true
      delegate_to: localhost

--
Vladimir Botka

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20240115160246.6e75ab7e%40gmail.com.

Attachment: pgpgcxf_bpF7F.pgp
Description: OpenPGP digital signature

Reply via email to