对于 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
最佳答案
你能试试这个吗:
- name: debug
debug: msg='hello'
when: repo == "repo1"
关于ansible:当条件与 var from include,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36908367/