Issue 1:
I upgraded from ansible 1.3 to ansible 1.6 and my asynchronous tasks are not working properly when those have to be SKIPPED. (when are not skipped everything works ok). This is my task to reproduce the error:

- name: Create screen session to run dd on new disk (async mode)
shell: /bin/dd if={{ ebs_device }} of=/dev/null bs=1024k
async: 36000
poll: 0
tags: rundd
when: ebs_iops != 0

This is executed as follows (Note: ebs_iops=0)

ansible-playbook -i cluster-oe setup.yml -s --ask-vault-pass --tags rundd

Output:

TASK: [common | Create screen session to run dd on new disk (async mode)] *****
skipping: [X.X.X.X]
Traceback (most recent call last):
File "/usr/bin/ansible-playbook", line 317, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/bin/ansible-playbook", line 257, in main
pb.run()
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 291, in run
if not self._run_play(play):
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 644, in _run_play
if not self._run_task(play, task, False):
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 421, in _run_task
results = self._run_task_internal(task)
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 385, in _run_task_internal
self.runner_callbacks.on_async_ok(host, res, poller.runner.vars_cache[host]['ansible_job_id'])
KeyError: 'ansible_job_id'
TASK: [common | Create screen session to run dd on new disk (async mode)] *****
skipping: [X.X.X.X]
Traceback (most recent call last):
File "/usr/bin/ansible-playbook", line 317, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/bin/ansible-playbook", line 257, in main
pb.run()
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 291, in run
if not self._run_play(play):
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 644, in _run_play
if not self._run_task(play, task, False):
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 421, in _run_task
results = self._run_task_internal(task)
File "/usr/lib/python2.6/site-packages/ansible/playbook/__init__.py", line 385, in _run_task_internal
self.runner_callbacks.on_async_ok(host, res, poller.runner.vars_cache[host]['ansible_job_id'])
KeyError: 'ansible_job_id'

Ansible version:

ansible --version
ansible 1.6.1

Issue 2:
Issue Type: Bug Report

Ansible Version:

1.6.1, devel

Environment:

Centos 6.5, OS X 10.9.2

Summary:

An async task with 'poll: 0' fails only when the 'when' condition causes it to be skipped. If I remove the poll option or set it to a number higher than 0, the task is successfully skipped. If I remove the 'when' condition, the async task is successful with 'poll' set to 0.

Steps To Reproduce:

Create an async task with 'poll: 0' and a when condition that causes it to be skipped.

- name: test
hosts: localhost

tasks:
- name: a local task
shell: echo hello
async: 30
poll: 0
when: a_variable is defined

Expected Results:

The async task should be skipped.

Actual Results:

TASK: [a local task] **********************************************************
skipping: [localhost]
Traceback (most recent call last):
File "/Users/jyoung/lib/ansible-main/bin/ansible-playbook", line 317, in <module>
sys.exit(main(sys.argv[1:]))
File "/Users/jyoung/lib/ansible-main/bin/ansible-playbook", line 257, in main
pb.run()
File "/Users/jyoung/lib/ansible-main/lib/ansible/playbook/__init__.py", line 319, in run
if not self._run_play(play):
File "/Users/jyoung/lib/ansible-main/lib/ansible/playbook/__init__.py", line 673, in _run_play
if not self._run_task(play, task, False):
File "/Users/jyoung/lib/ansible-main/lib/ansible/playbook/__init__.py", line 449, in _run_task
results = self._run_task_internal(task)
File "/Users/jyoung/lib/ansible-main/lib/ansible/playbook/__init__.py", line 413, in _run_task_internal
self.runner_callbacks.on_async_ok(host, res, poller.runner.vars_cache[host]['ansible_job_id'])
KeyError: 'ansible_job_id'