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/ba4fe79a-abf9-46a3-b658-682288b08643n%40googlegroups.com.

Reply via email to