【发布时间】:2016-12-04 06:51:05
【问题描述】:
例如:
我有想要使用的变量 {{ ami_redhat_7_2 }}
vars:
OsType: redhat
OsVersion: '7_2'
tasks:
- debug: 'msg="{{ ami_{{OsType}}_{{ OsVersion }} }}"'
我收到错误:
fatal: [localhost]: FAILED! => {
"failed": true,
"msg": "template error while templating string: expected token 'end of print statement', got '{'. String: {{ ami_{{ OsType }}_{{ OsVersion }} }}"
}
【问题讨论】:
-
你试过了吗:-调试:msg="{{vars["ami_" ~ OsType ~ "_" ~ OsVersion]}}"