Gri*_*cat 0 ansible ansible-playbook
我试图在ansible中的when语句中使用变量,我的代码片段如下所示:
- name: git repo for non prod env
git:
repo=http://url/repo.git
dest=/opt/dest
version={{ bld_env }}
when: ( "{{ bld_env }}" == "rc" ) or ( "{{ bld_env }}" == "sandbox" ) or ( "{{ bld_env }}" == "dev" ) or ( "{{ bld_env }}" == "qa" )
Run Code Online (Sandbox Code Playgroud)
这不起作用,并给出一个错误:
The offending line appears to be:
version={{ bld_env }}
when: "{{ bld_env }}" == "rc"
^ here
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)
让我知道我错在哪里.
| 归档时间: |
|
| 查看次数: |
5761 次 |
| 最近记录: |