ansible - 跳过传递给任务 ansible 的循环的多个值
问题描述
如何从寄存器输出(来自上一个任务)传递的循环中过滤掉不需要的值
代码
# 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 }}"
我怎样才能跳过只root
传递给 {{item.0}} ?
谢谢
解决方案
您可以添加如下条件
- name: with_together
debug:
msg: "{{ item.0 }} - {{ item.1 }}"
when: item.0 != 'root'
with_together:
- "{{ list_one }}"
- "{{ list_two }}"
推荐阅读
- linux - In Bash, is there a way to expand variables twice in double quotes?
- c++ - 如何抽象模板函数中使用的simd代码
- swift - 如何在 Xcode 9 中将键盘类型数字键盘限制为仅限英文数字
- apache-kafka - 如何部署 Yolean Kubernetes Kafka?
- gradle - AnnotationProcessor 和依赖项
- ios - 表达式太复杂,无法在合理的时间内解决(xcode)
- oracle - Oracle Reports 11g 中的字体
- scala - 基于委托的类型类编码有什么问题
- css - Rails js.erb 没有添加 css.animate 但没有错误
- javascript - 碰撞实现