为什么这不起作用:
---
- hosts: all
vars:
input_version: 99
- include: ./tagger_1.yml input="{{ input_version }}"
孩子是:
---
- name: build tagger docker
hosts: all
vars:
version: "11.0"
tasks:
- name: some step !!!!!!
command: echo {{ version }}
echo打印孩子,但我想用父输入参数覆盖它。可行?
changed: [localhost] => {"changed": true, "cmd": ["echo", "11.0"], "delta": "0:00:00.010476", "end": "2016-06-23 13:21:44.091857", "invocation": {"module_args": {"_raw_params": "echo 11.0", "_uses_shell": false, "chdir": null, "creates": null, "executable": null, "removes": null, "warn": true}, "module_name": "command"}, "rc": 0, "start": "2016-06-23 13:21:44.081381", "stderr": "", "stdout": "11.0", "stdout_lines": ["11.0"], "warnings": []}
答案 0 :(得分:0)
您echo {{ version }}
,但在父级中设置变量输入。
如果你command: echo {{ input }}
它应该有效。
如果您想要的是覆盖直接在儿子中定义的var,我认为您可以,由于变量优先。
for ansible 1.x
优先级如下(最后列出的变量赢得优先顺序):
for ansible 2.x