ansible 变量
- 变量可存放于多处位置
- roles
- vars/main.yml
- tasks/main.yml
- handlers/main.yml
- playbook
ansible变量过滤器
1. 变量类型
1. 不可迭代的基本数据
1. 字符串
2. 数字
3. null值
2. 可迭代的复合数据
1. 列表
2. 字典
3. 嵌套列表
4. 一组字典的列表(items)
2. 通用变量过滤器
- mandatory
- default
3. 基础变量过滤器
- 数字
+ - * / // % * **
- 字符串
- replace
- regex_replace
- 首字母大写
- 等字符串处理函数
- 列表
- max
- min
- length
- first
- sort
- unique
- reverse
- 下标取值
- 字典
- dict2items
- items2dict
4. 特殊处理过滤器
- 密码过滤器
- 二进制与编码的转换
5. 复杂数据格式处理
- json_query
- to_json, to_yaml,to_nice_json, to_nice_yaml
- from_json, from_yaml
6. 万能处理插件 Lookup / query
- file
- template
- pipe
- lines
- url
- password
7. 可迭代对象(列表,字典,嵌套数据)
- with_xxx 和 loop 可进行相互替代
- with_item 和 loop + flatten
- with_subelements 和 loop + subelements
- with_fileglob 和 loop + fileglob