参数 | 释义 | 示例 |
---|---|---|
defined | 变量已定义 | when: username is defined |
undefind | 变量未定义 | when: username is undfined |
none | 变量已定义未赋值 | when: username is none |
- hosts: all
tasks:
- name: test defined
vars:
username: test1
debug:
msg: "{{ username }} is defined"
when: username is defined
- name: test undefined
vars:
debug:
msg: "username is undefined"
when: username is undefined
- name: test none
vars:
username:
debug:
msg: "{{username}} is none"
when: username is none
标签:语句,username,none,判断,变量,vars,defined,when
From: https://www.cnblogs.com/wangend/p/17066004.html