问题原文
原帖链接 · Ryan · CC BY-SA 3.0
Is it possible to force Ansible when replacing the var in yml files, which is undefined, throw out an error instead silently replaced by an empty string?
社区高分解答
原帖链接 · dawud · CC BY-SA 3.0
Yes, it is possible. Check the online documentation, under accessing complex variable data.
An example is provided to do exactly that:
tasks:
- shell: echo "I've got '{{ foo }}' and am not afraid to use it!"
when: foo is defined
- fail: msg="Bailing out: this play requires 'bar'"
when: bar is not defined
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
