gpt4 book ai didi

ansible - 检查异步 Ansible 任务的标准输出

转载 作者:行者123 更新时间:2023-12-02 15:46:46 25 4
gpt4 key购买 nike

如何基于异步 Ansible 任务的 stdoutfailed_when?我尝试过以下变体:

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

这会导致:

fatal: [localhost] => error while evaluating conditional: "Finished 'command'" in result.stdout

最佳答案

任务完成后,使用async_status获取异步任务的状态:

- 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

关于ansible - 检查异步 Ansible 任务的标准输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36999933/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com