我正在请求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"}
答案 0 :(得分:0)
尝试
settings.py
答案 1 :(得分:0)
运气不好使我摆脱了痛苦
url: "{{ cora_response.json['@odata.mediaReadLink'] }}"