0
當我嘗試使用稍後在curl命令中使用的回聲生成一個curl請求部分時,我有一個Ansible任務。任務如下所示:當使用變量嘗試回顯某些內容時出現Ansible問題
- name: Generate requestcode
shell: echo '{ title: '{{get_hostname.stdout}}', key: '{{ssh_pu_key.stdout}}' }'
debug: msg: { title: '{get_hostname.stdout}'}
register: curl_request
我看到時,我嘗試運行代碼的錯誤是:
ERROR! Syntax Error while loading YAML.
The error appears to have been in '/root/wifirush.yml': line 54, column 26, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Generate requestcode
shell: echo '{ title: '{{get_hostname.stdout}}', key: '{{ssh_pu_key.stdout}}' }'
^here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
任何建議如何使這項工作?
我得到更新的答案同樣的錯誤 – zozo6015
。 – techraf
工作。謝謝,我不知道如何逃避那些專欄。 – zozo6015