当变量存在时执行命令、当变量不存在时执行命令.note
当变量存在时执行命令:
when: hostname is defined
当变量不存在时执行命令:
when: hostname is not defined还有另外一种 jinja2的写法,定义一个默认值:
当hostname存在时就使用hostname变量,当它不存在时就是用 inventory_hostname变量

当变量存在时执行命令:
when: hostname is defined
当变量不存在时执行命令:
when: hostname is not defined