Open
Description
Summary
When a file is uploaded with ansible.builtin.uri
via form-multipart, this task fails and is retried, all following retries fail because the module changes the path to the file.
Issue Type
Bug Report
Component Name
uri
Ansible Version
$ ansible --version
ansible [core 2.19.0.dev0] (devel 6cc97447aa) last updated 2025/04/17 10:38:23 (GMT +200)
config file = None
configured module search path = ['/home/zdenek/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/zdenek/pers/ansible/lib/ansible
ansible collection location = /home/zdenek/.ansible/collections:/usr/share/ansible/collections
executable location = /home/zdenek/pers/ansible/bin/ansible
python version = 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] (/usr/bin/python)
jinja version = 3.1.2
pyyaml version = 6.0.1 (with libyaml v0.2.5)
Configuration
# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
CONFIG_FILE() = None
OS / Environment
Ubuntu 24.04.2
Steps to Reproduce
- hosts: localhost
gather_facts: no
tasks:
- uri:
url: https://httpbin.org/post
method: POST
body_format: form-multipart
body:
file:
filename: /dev/null
retries: 1
delay: 0.01
register: result
failed_when: result.attempts == 1 or result is failed
Expected Results
Task succeeds on the second attempt
Actual Results
The full traceback is:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/ansible/plugins/action/uri.py", line 71, in run
filename = self._find_needle('files', filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ansible/plugins/action/__init__.py", line 1429, in _find_needle
return self._loader.path_dwim_relative_stack(path_stack, dirname, needle)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/ansible/parsing/dataloader.py", line 341, in path_dwim_relative_stack
raise AnsibleFileNotFound(file_name=source, paths=[to_native(p) for p in search])
ansible.errors.AnsibleFileNotFound: Could not find or access '/home/zdenek/.ansible/tmp/ansible-tmp-1744899011.7343578-77556-207993082232598/null' on the Ansible Controller.
If you are using a module and expect the file to exist on the remote, see the remote_src option
fatal: [localhost]: FAILED! => {
"attempts": 1,
"changed": false,
"failed_when_result": true,
"msg": "Could not find or access '/home/zdenek/.ansible/tmp/ansible-tmp-1744899011.7343578-77556-207993082232598/null' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"
}
Code of Conduct
- I agree to follow the Ansible Code of Conduct