title: Ansible : APT module: how to get stdout?
body: <p>Using the following answer <a href="https://stackoverflow.com/questions/34026875/ansible-apt-get-install-output">stackoverflow.com/questions/34026875/</a>
  I'm trying to get the stdout from ansible apt module.</p>
  
  <p>Using this very simple test playbook:</p>
  
  <pre><code>- hosts: localhost
    sudo: true
    tasks:
      - name: 'apt: update &amp; upgrade'
        apt:
          update_cache: yes
          cache_valid_time: 3600
        register: apt
      - debug: msg={{ apt.stdout.split('\n')[:-1] }}
  </code></pre>
  
  <p>I always have this error message:</p>
  
  <blockquote>
    <p>fatal: [localhost]: FAILED! => {"msg": "The task includes an option
    with an undefined variable. The error was: 'dict object' has no
    attribute 'stdout'</p>
  </blockquote>
  
  <p>I have tried with many way (install package, remove, ... ) and always have the same error message.</p>
  
  <p>Using <code>debug: msg=apt</code> the only output message that I can have is <code>{"cache_update_time": 1531941358, "cache_updated": true, "changed": true}</code> even if I install or remove a package which is for me in my humble opinion an output message which means nothing clear, because <code>"cache_updated": true, "changed": true</code> doe not mean that packages have been installed or removed.</p>
  
  <p>In the Ansible APT module documentation <a href="https://docs.ansible.com/ansible/latest/modules/apt_module.html" rel="nofollow noreferrer">Ansible APT Module Documentation</a>
  Return Values section, there is a stdout returned <code>success, when needed</code>.</p>
  
  <p>Does anyone know how to get a real and clear exit from the Ansible APT module or how to force Ansible to return a stdout (ansible config, ...) and what really means <code>"success, * when needed *"</code> because i never managed to get a stdout output under any circumstances.</p>
  
  <p>Kind Regards</p>