Is there a way to use the ansible.builtin.uri module to post / put an encrypted file while seamlessly decrypting it from the vault? Or is there a safe workaround (i.e. a secure sequence of tasks?).
The use case is to upload a licence file which is stored encrypted with ansible vault in the roles/the_role/files folder of a project.
The ansible.builtin.uri module is able to find the encrypted file, but it does not decrypt it before the upload.
- name: "Nexus Update License: Uploading new License file"
ansible.builtin.uri:
url: "http://{{ inventory_hostname }}:{{ nexus_default_port }}{{ nexus_default_context_path | regex_replace('\\/$', '')}}/service/rest/v1/system/license"
user: "{{ nexus_admin_account }}"
password: "{{ nexus_admin_password }}"
headers:
Content-Type: application/octet-stream
method: POST
force_basic_auth: yes
status_code: 200,204
src: "license.lic.enc" # this uploads the license still encrypted...
This question is similar, but I cannot use the copy module: How to upload encrypted file using ansible vault?