-2
说我有20-25像3字典变量在我如何遍历2个或更多的字典项目?
角色/默认设置如下图所示/ main.yml
severName:
server1: ngrt008
server2: ngrt009
hostName_North:
host1: northwest
host2: northeast
hostName_South:
host1: southwest
host2: southeast
现在我还有一个文件,列出了,我想这些循环变量字典过度。
说法,list.yml
required_dict_vars:
- hostName_North
- severName
我想遍历这些字典在pretask变量值(即ngrt008,ngrt009,西北,东北),以验证这些都是字符串。 我正在使用assert来验证它的一个字符串,但我无法循环它们。
- name: Check if values are of type string
assert:
that: "{{ item }} is string"
msg: "The value is not of type string"
with_items:
- "{{ required_dict_vars.values() | list }}"