【问题标题】:Ansible does not cancel a job after running into fata error (awx)Ansible 在遇到 fata 错误 (awx) 后不会取消作业
【发布时间】:2020-11-09 10:50:06
【问题描述】:

我有以下关于 ansible (awx) 的问题: 当 Job 以 fatal: [IP]: FAILED! 失败时,ansible 不会取消此作业,并且 awx 会一直显示“正在运行”。我需要取消那些很烦人的工作手册。 ansible 失败的原因在这里无关紧要。 我试图通过添加来解决这个问题

- name: Fail task when the command error output prints FAILED
  ansible.builtin.command: /usr/bin/example-command -x -y -z
  register: command_result
  failed_when: "'FAILED' in command_result.stderr"

在剧本的顶部,但它不起作用。

如果你有任何想法......

谢谢!

【问题讨论】:

    标签: ansible ansible-awx


    【解决方案1】:

    Playbooks 支持异步模式,如果您需要为您的任务设置超时,您可以使用它。 Ansible 等待任务完成、失败或超时。为此,您应该使用 asyncpoll 参数,async 确定任务的超时时间,poll 确定时间,以便 ansible 检查任务的状态。两者都必须以秒为单位。

    你可以尝试如下

    - name: Fail task when the command error output prints FAILED
      ansible.builtin.command: /usr/bin/example-command -x -y -z
      register: command_result
      async: 60
      poll: 15
    

    更多信息:

    https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html#asynchronous-playbook-tasks

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多