ansible 变量检测是否定义,ansible变量


如果需要的变量没有定义,那么可以skip或者使用jinja2的defined如下所示:

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 undefined

---
- name: echo variable
  when:
    - api_interface is defined
    - neutron_external_interface is defined
    - storage_interface is undefined
  pause: seconds=10
 

 

参考:https://blog.csdn.net/kellyseeme/article/details/50609591

相关内容

    暂无相关文章