Ansible: Perform a failed_when: on an async task based on a value from stdout

后端 未结 1 1128
礼貌的吻别
礼貌的吻别 2021-01-18 04:16

I am trying to perform a failed_when: on an async task based on a value from stdout.

This is my task:

  - name: RUN SOME TASK LOCALLY
           


        
相关标签:
1条回答
  • 2021-01-18 04:41

    You may help ansible to avoid templating crash because of undefined variable.
    Change fail_when: like this:

    failed_when: "poll_status.stdout is defined and 'ERROR' in poll_status.stdout"
    

    If job is not finished by the first run of polling task, stdout is not yet populated and thus undefined, causing templating engine to crash.

    0 讨论(0)
提交回复
热议问题