在Ansible中,可以使用'loop”关键字来循环遍历列表中的列表。下面是示例代码:
- name: Loop through list of lists in Ansible
hosts: localhost
vars:
my_list:
- [1, 2, 3]
- ['a', 'b', 'c']
tasks:
- name: Print each item in the list of lists
debug:
msg: "{{ item }}"
loop: "{{ my_list }}"
在这个例子中,'my_list”将包含两个列表。这个任务使用'loop”关键字来循环遍历列表中的每个列表。在每次迭代中,'item”变量都将被设置为当前列表,并使用'debug”模块打印出来。