0
我下面写的代码使用ansible URI模块错误而使用REST API
- name: Upload tar.gz file
hosts: localhost
tasks:
- name: Upload tar.gz file
uri:
url: "<url>/upload_tar_gz"
method: POST
HEADER_Content-Type: "multipart/form-data"
force_basic_auth: yes
user: "{{username}}"
password: "{{password}}"
status_code: 200
validate_certs: no
return_content: yes
body_format: json
body: "{{ lookup('file','test_file.tar.gz') }}"
上传通过REST API的tar.gz文件通过URI模块上传tar.gz文件,但得到一个错误如下:
fatal: [localhost]: FAILED! => {"failed": true, "msg": "An unhandled exception occurred while running the lookup plugin 'file'. Error was a , original message: 'utf8' codec can't decode byte 0x8b in position 1: invalid start byte"}
看起来像文件插件无法加载tar.gz文件。有什么具体的原因呢?