问题描述
我们是否能够使用ansible的URI模块将文件上传到nexus,而不是使用 curl --upload-file作为shell任务?
解决方法
从2.7版本开始,uri
模块具有一个src
参数,应该可以解决问题。
因此,这是一项任务(以适应/完成Nexus API的行为):
- name: Push jar to nexus
uri:
url: "{{ nexus_url }}/nexus/content/repositories/{{ path_repository }}/{{ artifact_name }}"
method: PUT
src: "{{ local_file_path }}"
user: "{{ user }}"
password: "{{ password }}"
force_basic_auth: yes
#headers:
# Content-Type: application/octet-stream # To avoid automatic 'application/x-www-form-urlencoded'
status_code:
- 201