ansible - Ansible 在遇到 fata 错误 (awx) 后不会取消作业
问题描述
我有以下关于 ansible (awx) 的问题:当作业失败时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"
在剧本的顶部,但它不起作用。
如果你有什么想法...
谢谢!
解决方案
Playbooks 支持异步模式,如果您需要为您的任务设置超时,您可以使用它。Ansible 等待任务完成、失败或超时。为此,您应该使用async
和poll
参数,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
推荐阅读
- sql - 难以理解逻辑。收入超过经理的员工。
- c# - .NET Core 中的 ConcurrentQueue.Count 非常慢
- javascript - javascript可以将目标URL下载到变量中吗?
- go - 如何在 Go 中将包含非数字字符的字符串拆分为字符串数组?
- java - Java 找不到像 addFirst 或 addLast 这样的方法
- java - MySQLNonTransientConnectionException 无法创建与数据库服务器的连接。引起:java.lang.NullPointerException
- testing - 使用 Spock 在不同的测试环境中运行测试
- jquery - 自动扩展输入框而不干扰其他块
- ruby-on-rails - GraphQL::Client::DynamicQueryError 期望的定义被分配给一个静态常量
- ocaml - 如何为嵌套递归数据定义数据类型