如何从循环中过滤掉不需要的值,这些值是从寄存器输出(从上一个任务)传递过来的]
代码
# assume the list_one below register values.
list_one = [root, a, b, c]
- name: with_together
debug:
msg: "{{ item.0 }} - {{ item.1 }}"
with_together:
- "{{ list_one }}"
- "{{ list_two }}"
我如何仅跳过传递到{{item.0}}的root
?
谢谢
您可以添加如下的when条件
- name: with_together
debug:
msg: "{{ item.0 }} - {{ item.1 }}"
when: item.0 != 'root'
with_together:
- "{{ list_one }}"
- "{{ list_two }}"