title: Ansible: How to inform a python script about the outcome of a task?
body: <p>I have simple playbook to fetch and copy files from a share to remote windows clients:</p>
  
  <pre><code>- name: Test chocolatey module
    hosts: win_clones
    vars_files:
    - /fullpath/hosts_vars
    tasks:
      - name: Fetching and copying the file on the client ...
        win_get_url:
          url: 'ftp://172.20.0.5/choco-repo/{{ item }}'
          dest: 'C:\Test\{{ item }}'
        with_items: "{{ clients[machine].to_install }}"
  </code></pre>
  
  <p>I run this play from a python script using subprocess:</p>
  
  <pre><code>for i in clients:
      machine = "machine="
      limit = "--limit="
      an2 = subprocess.Popen(["ansible-playbook", "fetch.yml","-e", machine+i, limit+i], cwd='/home/diego/work/gitl_repo/ansible-software-deployment')
      an2.wait()
  </code></pre>
  
  <p>When a task fails for whatever reason I can see that in my terminal:</p>
  
  <pre><code>TASK [Fetching and copying the file on the client ...] *************************
  failed: [cl1] (item=banana) =&gt; {"failed": true, "item": "banana", "msg": "Error downloading ftp://172.20.0.5/.....
  </code></pre>
  
  <p>Is it possible to pass this information to my python script? In other words, How could I tell python about the outcome of a certain task, i.e. if it failed or if it went through. Thanks  </p>