【发布时间】:2018-08-08 08:20:03
【问题描述】:
我有复杂的字典结构,我想检查是否定义了子键。我什至不知道这是否可能..
这是我的字典的样子:
config:
1:
client: ubuntu
network_setup:
- routed
ports:
sw1: null
sw2:
client: 1/0/2
lte: 1/0/5
2:
client: archlinux
network_setup:
- bridged
ports:
sw1:
client: 1/0/4
sw2: null
...
注意:无法定义 lte 密钥!
我想要检查 lte 是否在配置字典中定义。理想情况下,我需要使用循环遍历 config 中的每个条目。
我可能会写一个自定义插件,因为这听起来很难做到..
【问题讨论】:
标签: loops dictionary ansible