Fro what it may be worth, using the yaml  stdout_callback, the output of 
debug looks like this:

ok: [myhost] =>
  msg:
  - paho-c-1.3.13-2.el9
  - cpp-11.4.1-2.1.el9
  - glibc-headers-2.34-83.el9_3.7
  - gnutls-dane-3.7.6-23.el9
  - insights-client-3.2.2-1.el9_2
  - libblockdev-2.28-7.el9
  - libblockdev-loop-2.28-7.el9
  - libfastjson-0.99.9-5.el9

On Monday, January 15, 2024 at 8:00:13 AM UTC-5 Dimitri Yioulos wrote:

> Good morning.
>
> Let me start by saying that I hope I'm not overdoing my asks. I only do it 
> when I've tried, but failed, at a solution. Nextly, I hope your kind 
> answers help others, as well. That said, the following playbook returns 
> packages that are set for update:
>
> ---
>
> - hosts: all
>   gather_facts: false
>
>   tasks:
>     - name: Check packages to upgrade
>       dnf:
>         list: updates
>       register: packages
>
>     - name: Show packages to upgrade
>       debug:
>         msg: >-
>           {%- set output=[] -%}
>           {%- for p in packages.results -%}
>           {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) 
> }}
>           {%- endfor -%}
>           {{ output }}
>
>     - local_action:
>         module: copy
>         content: |
>           {% for host in ansible_play_hosts %}
>           {{ host }}:
>           The following packages will be updated
>
>           {%- set output=[] -%}
>           {%- for p in packages.results -%}
>           {{ output.append((p.name ~ '-' ~ p.version ~ '-' ~ p.release)) 
> }}
>           {%- endfor -%}
>           {{ output }}
>           {% endfor -%}
>
>         dest: "/tmp/installed.txt"
>       run_once: yes
>       tags:
>         - report
>
> It works fine through the debug play:
>
> ok: [myhost] => {
>     "msg": [
>         "paho-c-1.3.13-2.el9",
>         "cpp-11.4.1-2.1.el9",
>         "glibc-headers-2.34-83.el9_3.7",
>         "gnutls-dane-3.7.6-23.el9",
>         "insights-client-3.2.2-1.el9_2",
>         "libblockdev-2.28-7.el9",
>         "libblockdev-loop-2.28-7.el9",
>         "libfastjson-0.99.9-5.el9",
>         ~
>
> However, the report play does not work. I would have thought that setting 
> it up like the debug play should do it, but no. How can I get that list of 
> updates, along with the hostname, into a textfile report?
>
> As ever, many thanks.
>

-- 
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/155fc3a9-fd10-494b-a37b-038beb45969fn%40googlegroups.com.

Reply via email to