ansible / ansible-modules-core

Ansible modules - these modules ship with ansible
1.3k stars 1.95k forks source link

async polling doesnt work #5900

Closed skanagal closed 7 years ago

skanagal commented 7 years ago

Hey Team,

Ansible Version: 2.2.1.0 and 2.1.2.0

So basically what I am trying to do is run a tcpdump on a device. While the tcpdump is running, I am running a ‘pinging’ task from another device. Once this task is complete, I go back and check what the tcpdump has captured. This feature in Ansible is termed as “fire and forget”. Reference: http://docs.ansible.com/ansible/playbooks_async.html

In my playbook I have the below:

- name: remkaring test - tcpdump for traffic sent with DSCP for
  eos_command:
    commands:
      - bash timeout 10 tcpdump -i ma1 -C 2 -v
    provider: "{{ provider|default(omit) }}"
  when: item ['role']=='dev2'
  with_items:
    - "{{ hostvars[inventory_hostname] }}"
  register: markingtest_marked
  async: 40
  poll: 0
  tags:
    - mkng

- name: 'Checking previous task'
  async_status: jid="{{ markingtest_marked.ansible_job_id }}"
  register: markingtest_marked_result
  until: markingtest_marked_result.finished
  when: item ['role']=='dev2'
  with_items:
    - "{{ hostvars[inventory_hostname] }}"
  retries: 30
  tags:
    - mkng

When I run the playbook I get an error that says "'dict object' has no attribute 'ansible_job_id'. I have attached the error log in the text file I attached. If any of you used this feature before, can you kindly take a look and let me know what might be missing here?

The error is:

error.txt "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'dict object' has no attribute 'ansible_job_id'\n\n

ansibot commented 7 years ago

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide.