我正在请求REST API为我提供特定项目的下载URL(这是由uri模块解决的)。然后我尝试在get_url模块中使用url,但它失败并显示以下消息
FAILED! => {"msg": "template error while templating string: expected name or number. String: {{ cora_response.json.['@odata.mediaReadLink'].stdout | from_json }}"}
我怎么想把变量放到url参数中?我的任务看起来像这样:
- name: Download Link from REST
debug: var=cora_response.json['@odata.mediaReadLink']
- name: Download the latest Release
get_url:
url: "{{ cora_response.json.['@odata.mediaReadLink'].stdout | from_json }}"
dest: "{{ installation_path }}/install/19.3.zip"
mode: 660
我的调试任务向我显示了我尝试使用的URL,但是get_url模块失败了。
请提前告知并提前感谢。
编辑:尝试@ al76建议的以下内容
- name: Download the latest CH Release
get_url:
url: "{{ cora_response.json['@odata.mediaReadLink'].stdout | from_json }}"
dest: "{{ installation_path }}/install/CH19.3.zip"
mode: 660
错误信息:
fatal: [ln-lnxcelcon01.owo.company]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ cora_response.json['@odata.mediaReadLink'].stdout | from_json }}): expected string or buffer"}
尝试
url: "{{ cora_response.json['@odata.mediaReadLink'].stdout | from_json }}"
盲目的运气让我摆脱了痛苦
url: "{{ cora_response.json['@odata.mediaReadLink'] }}"