Playbook randomly dies after async/poll

Hey. I’m having an issue in Ansible 1.9.4 where a playbook just stops running. No errors or anything, the process just dies. It seems to happen at random places when running the playbook, but it all seems to happen after these two steps:

  • name: Fire async to watch build
    shell: “CONTAINER=my_{{ timestamp }} /app/deploy/watch-docker.sh”
    async: 1200
    poll: 15
    register: watch_docker
    ignore_errors: true

  • name: Wait until built
    async_status:
    jid: “{{ watch_docker.ansible_job_id }}”
    register: job_result
    until: job_result.finished
    retries: 100
    delay: 15
    ignore_errors: true

Is it possible that after the async shell call, the process dies on the next poll? Turning on verbose didn’t seem to help. I also tried raising the timeout to 30 in ansible.cfg, but that also did nothing. If I take out these two actions and replace them with a pause action, the playbook completes. Any ideas? I’m pretty stuck on this one…

For reference, here’s the watch-docker script:

// watch-docker.sh
#!/bin/bash
if [ ! -z $CONTAINER ]; then
while true; do
docker exec $CONTAINER pgrep php5-fpm
catch=$?
if [ $catch -eq 0 ]; then
break
fi
sleep 5
done
fi
exit 0

Update: I think it has to do with the poll: 15 in the first task. Setting that to 0 seems to make it work. Why is the polling there causing an issue?

Because if you use poll > 0 then job finishes before the next task starts so I guess `watch_docker` register doesn't contain `ansible_job_id` property?

If you set it to 0, then job runs in background.