【发布时间】:2015-06-17 05:46:27
【问题描述】:
我写了一个如下的任务,但不明白'|'是什么有吗?
tasks:
- shell: /usr/bin/foo
register: result
ignore_errors: True
- debug: msg="it failed"
when: result|failed
- debug: msg="it changed"
when: result|changed
我也在网上找到了一些例子,但不明白什么是'|'有吗?
debug: msg={{ ipaddr |replace(",", ".") }}
再举一个例子:
- hosts: localhost
vars:
D:
1 : "one"
2 : "two"
tasks:
- debug: var=D
- debug: msg="D[1] is {{ D[1]|default ('undefined') }}"
如果有人可以详细解释或指向我的某个 URL,那就太好了?
任何帮助将不胜感激。
谢谢。
【问题讨论】:
-
你检查jinja docs了吗?
-
我在我维护的代码中看到了这一点,并认为“Python 有像 shell 一样的管道!?”。感谢这个问题让我明白了!