Asynchronous 轮询为0的Ansible异步模块不';我不能完成任务

Asynchronous 轮询为0的Ansible异步模块不';我不能完成任务,asynchronous,ansible,Asynchronous,Ansible,首先,我使用的是ansible2.0.0(我无法避免) 我有这样的任务。在这里,我使用ping命令将流量发送到目标机器2分钟。此命令在远程计算机上运行 - name: Ping destination VM from host VM. shell: ping -n -i 0.004 100.1.1.1 -c 30000 | grep "received" | cut -d"," -f2 | xargs | cut -d" " -f1 delegate_to: 172.25.11.207

首先,我使用的是
ansible2.0.0
(我无法避免)

我有这样的任务。在这里,我使用
ping
命令将流量发送到目标机器2分钟。此命令在远程计算机上运行

- name: Ping destination VM from host VM.
  shell: ping -n -i 0.004 100.1.1.1 -c 30000 | grep "received" | cut -d"," -f2 | xargs | cut -d" " -f1
  delegate_to: 172.25.11.207
  async: 250
  poll: 0
  register: ping_result
  failed_when: ping_result.rc != 0
在此之后,我还有2-3项其他任务。这不应该超过一分钟

现在,在完成这些任务之后,我想捕获ping_结果的输出。因此,我检查上述任务的状态,如下所示:

- name: Check ping status
  async_status:
    jid: "{{ ping_result.ansible_job_id }}"
  register: job_result
  until: job_result.finished
  retries: 10
现在,此操作失败,出现以下错误:

失败!=>{“failed”:true,“msg”:“ERROR!条件检查'job_result.finished'失败。错误为:ERROR!计算条件(job_result.finished)时出错:ERROR!dict object'没有属性'finished'”

从错误中可以看出,原始任务似乎尚未完成。我甚至尝试增加
async
时间,比如说直到5000。不走运


如果您对此有任何帮助,我们将不胜感激。

请回答以下评论:

您应该使用
delegate_to
检查异步作业的状态,因为原始
async
任务也已被委派


下面的内容对我有用

until: job_result.finished is defined and job_result.finished

为什么要将异步作业委托给其他主机,但在不委托的情况下检查状态?Ansible playbook在测试服务器上运行。但是命令(在我的例子中是ping)应该在不同的服务器上运行。因此,我在运行任务时使用“delegate_to”。我应该在检查状态时也使用“委派”吗?@KonstantinSuvorov-你能确认上述内容吗?在检查状态时是否也需要使用“委托人”?是的,您应该使用
delegate\u to
检查状态。你还没试过吗?!非常感谢KonstantinSuvorov。成功了!