使用ansible 1.9.2我有一个角色::
- include: snippet.yml repo=rep1
- include: snippet.yml repo=rep2
- include: snippet.yml repo=rep2
在snippet.yml
我有::
- name: debug
debug: msg='hello'
when: rep1 == {{ repo }}
但我收到此错误消息::
fatal: [vagrant] => error while evaluating conditional: rep1 == rep1
FATAL: all hosts have already failed -- aborting
当我使用@arbabnazar ::
提出的第一语法时- name: debug
debug: msg='hello'
when: "rep1 == {{ repo }}"
我收到此错误::
TASK: [stack | debug] *******************************************
fatal: [vagrant] => error while evaluating conditional: rep1 == rep1
FATAL: all hosts have already failed -- aborting
使用@arbabnazar ::
提出的第二种语法- name: debug
debug: msg='hello'
when: "rep1 in {{ repo }}"
我收到此错误::
TASK: [stack | debug] *******************************************
fatal: [vagrant] => error while evaluating conditional: rep1 in rep1
FATAL: all hosts have already failed -- aborting
答案 0 :(得分:1)
你可以试试这个:
- name: debug
debug: msg='hello'
when: repo == "repo1"