title: Read name of directory created using ansible's tempfile module
body: <p>I wrote a simple ansible script to create a temporary directory and want to save the name of this directory into a variable. My <code>.yml</code> file is:</p>
  
  <pre><code>- hosts: " {{ lookup('env', 'HOSTNAME') }} "
    tasks:
    - name : Create staging directory
      tempfile:
        state: directory
        suffix: staging
        path: "{{ lookup('env', 'HOME') }}"
      become: true
      register: output
  
    - name: print stdout
      debug: msg="{{ output }}"
  </code></pre>
  
  <p>The output from running the above prints a <code>dict</code></p>
  
  <pre><code>$ ansible-playbook -i hosts tempfile.yml  
  
  PLAY [localhost] ******************************************************************************************
  
  TASK [Gathering Facts] ************************************************************************************
  ok: [localhost]
  
  TASK [Create staging directory] ***************************************************************************
  changed: [localhost]
  
  TASK [print stdout] ***************************************************************************************
  ok: [localhost] =&gt; {
      "msg": {
          "changed": true, 
          "gid": 0, 
          "group": "root", 
          "mode": "0700", 
          "owner": "root", 
          "path": "/home/xxxx/ansible.Fb7rbKstaging", 
          "size": 4096, 
          "state": "directory", 
          "uid": 0
      }
  }
  
  PLAY RECAP ************************************************************************************************
  localhost                  : ok=3    changed=1    unreachable=0    failed=0   
  </code></pre>
  
  <p>How do I get access to <code>some_dict['localhost']['msg']['path']</code>? I looked up the <code>hostvars</code> variable and do see my temporary directory in it, but can't figure out how to get access to it.</p>