-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 }}"