Playbooks 中的错误处理
有时一条命令会返回 0 但那不是报错.有时命令不会总是报告它 ‘改变’ 了远程系统.本章节描述了如何将 Ansible 处理输出结果和错误处理的默认行为改变成你想要的.
New in version 0.6.
通常情况下, 当出现失败时 Ansible 会停止在宿主机上执行.有时候,你会想要继续执行下去.为此你需要像这样编写任务:
New in version 1.4.
假设一条命令的错误码毫无意义只有它的输出结果能告诉你什么出了问题,比如说字符串 “FAILED” 出现在输出结果中.
在 Ansible 1.4及之后的版本中提供了如下的方式来指定这样的特殊行为:
New in version 1.3.
When a shell/command or other module runs it will typically report“changed” status based on whether it thinks it affected machine state.当一个 shell或命令或其他模块运行时,它们往往都会在它们认为其影响机器状态时报告 “changed”状态
- 有时你可以通过返回码或是输出结果来知道它们其实并没有做出任何更改.你希望覆写结果的
See also
- Playbooks
- An introduction to playbooks
- Best practices in playbooks
- 条件选择
- All about variables
- User Mailing List
- Have a question? Stop by the google group!