问题描述
我遇到有关ansible(awx)的以下问题:
当作业因There was an unexpected error (type=Method Not Allowed,status=405).
Request method 'GET' not supported
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported
而失败时,ansible不会取消该作业,并且awx永远显示“正在运行”。我需要取消那些烦人的工作手册。
ansible失败的原因在这里并不重要。
我尝试通过添加
fatal: [IP]: Failed!
位于剧本的顶部,但无法使用。
如果您有任何想法...
谢谢!
解决方法
剧本支持异步模式,如果您需要为任务设置超时时间,则可以使用它。 Ansible等到任务完成,失败或超时。为此,您应该使用async
和poll
参数,async
设置任务的超时时间,poll
设置时间以检查任务的状态。两者都必须在几秒钟内。
您可以尝试如下
- 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