Ansible變量,例如:如何建立從字符串
我有變量{{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 }} }}"
}
您是否嘗試過: - debug:msg =「{{vars [」ami_「〜OsType〜」_「〜OsVersion]}}」 – Shasha99