标签:语句 判断 变量 vars debug when test msg name
参数 |
释义 |
string |
判断字符串 |
upper |
判断全大写 |
lower |
判断全小写 |
- hosts: all
tasks:
- name: test string
vars:
msg: ABC
debug:
msg: "{{ msg }} is string"
when: msg is string
- name: test upper
vars:
msg: ABC
debug:
msg: "{{ msg }} is upper"
when: msg is upper
- name: test lower
vars:
msg: abc
debug:
msg: "{{ msg }} is lower"
when: msg is lower
参数 |
释义 |
number |
判断是数字 |
odd |
判断是奇数 |
even |
判断是偶数 |
- hosts: all
tasks:
- name: test number
vars:
msg: 123
debug:
msg: "{{ msg }} is number"
when: msg is number
- name: test odd
vars:
msg: 123
debug:
msg: "{{ msg }} is odd"
when: msg is odd
- name: test even
vars:
msg: 124
debug:
msg: "{{ msg }} is even"
when: msg is even
参数 |
释义 |
subset() |
判断列表子集 |
superset() |
判断列表父集 |
- hosts: all
vars:
var1: [a,b,c]
var2: [a]
tasks:
- name: test subset
debug:
msg: "{{var2}} in {{ var1 }}"
when: var2 is subset(var1)
- name: test superset
debug:
msg: "{{var1}} include {{ var2 }}"
when: var1 is superset(var2)
标签:语句,
判断,
变量,
vars,
debug,
when,
test,
msg,
name
From: https://www.cnblogs.com/wangend/p/17066028.html