The first one lists all the rpms installed on the system.
The second one list only the available updates. Perhaps there are none?

You'll have to convince me that debug output ends up in either 
/tmp/updates.txt or /tmp/installed.txt. I'm highly skeptical of that claim.

On Friday, December 8, 2023 at 8:23:22 AM UTC-5 Dimitri Yioulos wrote:

> Good day!
>
> I guess I'm fond of creating reports from debug output. Well, actually, I 
> have a business case for doing so. I have a couple of playbooks that I've 
> set up to create report:
>
> playbook 1 -
>
> ---
>
> - hosts: host1
>   gather_facts: false
>   become: yes
>
>   tasks:
>
>     - name: yum_command
>       shell: rpm -qa|sort -n
>       register: packages
>
>     - debug:
>         var: packages
>
>     - local_action:
>         module: copy
>         content: |
>           {% for host in ansible_play_hosts %}
>           {{ host }}:
>
>           The following packages are installed
>
>           {{ hostvars[host]['packages']['stdout']|default("None", true) }}
>
>
>           {% endfor -%}
>         dest: "/tmp/installed.txt"
>       run_once: yes
>       tags:
>         - report
>
> playbook 2 -
>
> ---
>
> - hosts: host1
>   gather_facts: false
>   become: yes
>
>   tasks:
>
>     - name: yum_command
>       yum:
>         list=updates
>       register: packages
>
>     - debug:
>         var: packages
>
>     - debug: var=item
>       with_items: "{{packages|json_query(jsonquery)}}"
>       vars:
>         jsonquery: "results[?name!='null'].envra"
>
>     - local_action:
>         module: copy
>         content: |
>           {% for host in ansible_play_hosts %}
>           {{ host }}:
>
>           The following packages will be updated -
>
>           {{ hostvars[host]['packages']['stdout']|default("None", true) }}
>
>
>           {% endfor -%}
>         dest: "/tmp/updates.txt"
>       run_once: yes
>       tags:
>         - report
>
> Playbook 1 creates the report, and populates it with debug output. 
> Playbook 2 created the report, but doesn't add debug output. Why? How can I 
> make playbook 2 include output
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e90a546a-a220-436a-87e8-0c3253a8f0a1n%40googlegroups.com.

Reply via email to