Mos*_*she 13 yaml concatenation ansible
在with_items为目标部分执行预处理时,我正在尝试多个连接.
现在它看起来像这样:
- name: create app except+lookup
copy: content="" dest="{{ dir.comp ~ '/config/con2dd/' ~ item.name ~ 'File.txt' }}" force=no group=devops owner=devops mode: 0755
with_items:
...
Run Code Online (Sandbox Code Playgroud)
我明白了:
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
Run Code Online (Sandbox Code Playgroud)
尝试了几种方法,但没有一种方法可以实现.
是否可以用字符串连接变量?
Kon*_*rov 12
不要为参数混合纯YAML和key = value语法.并且始终将YAML语法用于复杂参数:
- name: create app except+lookup
copy:
content: ""
dest: "{{ dir.comp }}/config/con2dd/{{ item.name }}File.txt"
force: no
group: devops
owner: devops
mode: 0755
with_items:
...
Run Code Online (Sandbox Code Playgroud)