跳过传递给任务ansible的循环的多个值

跳过传递给任务ansible的循环的多个值,ansible,ansible-2.x,ansible-inventory,ansible-facts,ansible-template,Ansible,Ansible 2.x,Ansible Inventory,Ansible Facts,Ansible Template,如何从寄存器输出(从上一个任务)传递的循环中过滤掉不需要的值 代码 如何仅跳过传递到{{item.0}的root 谢谢您可以添加以下when条件 - name: with_together debug: msg: "{{ item.0 }} - {{ item.1 }}" when: item.0 != 'root' with_together: - "{{ list_one }}" - "{{ list_two }}" - n

如何从寄存器输出(从上一个任务)传递的循环中过滤掉不需要的值

代码

如何仅跳过传递到{{item.0}的
root


谢谢

您可以添加以下when条件

  - name: with_together
    debug:
      msg: "{{ item.0 }} - {{ item.1 }}"
    when: item.0 != 'root'
    with_together:
     - "{{ list_one }}"
     - "{{ list_two }}"

  - name: with_together
    debug:
      msg: "{{ item.0 }} - {{ item.1 }}"
    when: item.0 != 'root'
    with_together:
     - "{{ list_one }}"
     - "{{ list_two }}"