Check async Ansible standard task

How can you failed_whenbased on stdoutthe async Ansible task? I tried the options:

- name: Run command
  command: arbitrary_command
  async: 3600
  poll: 10
  register: result
  failed_when: "Finished 'command'" in result.stdout

It leads to:

fatal: [localhost] => error while evaluating conditional: "Finished 'command'" in result.stdout
+4
source share
1 answer

Get the status of an asynchronous task with async_statusafter completing the task:

- name: Run command
  command: arbitrary_command
  async: 3600
  poll: 10
  register: result_async

- name: Check command
  async_status: jid="{{ result_async.ansible_job_id }}"
  register: result
  failed_when: result.finished != 1 or "Finished 'command'" not in result.stdout
+5
source

All Articles