You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Almost all Ansible operations appear to use the unresolved path to the Ansible temp directory '~/.ansible/tmp'. However, the ansible.builtin.copy module appears to resolve this path to '/root/.ansible/tmp' when looking for the source file. The underlying problem is that when I examined the filesystem on the VM, it appears that the community.libvirt.libvirt_qemu connection plugin is copying all files in the temp directory to '/~/.ansible/tmp'. The tilde is not being resolved to the homedir of the user and instead ends up in a '/~' directory at the root of the filesystem.
ansible -i local-libvirt-inventory.yml --become all -m copy -a 'src=srcfile dest=/path/to/dest/file'
EXPECTED RESULTS
The local file is copied to the libvirt host.
ACTUAL RESULTS
The file is not copied. When examining the filesystem in the libvirt VM, I found that the directory '/root/.ansible/tmp' doesn't exist. It is located at '/~/.ansible/tmp' instead.
The libvirt_qemu connection module uses QEMU guest agent to copy files
and run commands on the remote host. Ansible uses the '~/' symbolic path
to the user's home directory for many commands and file paths.
Unfortunately, since QEMU guest agent doesn't run in a shell, it doesn't
resolve the '~/' path to the user's homedir.
Instead, the Ansible paths end up at '/~/' in the remote host. This
breaks some assumtions for some modules about the path to the Ansible
files. Some modules use the resolved homedir path and fail to find any
files in that location.
This fix first resolves the remote user homedir with a QEMU guest
command, caches the result, and then replaces '~/' found in any command
or remote file paths with the resolved absolute path to the user's
homedir.
@antonc42 hi, thanks for posting this issue. I've been trying to replicate it and didn't have luck with various versions of ansible and python on Fedora and CentOS. I spun up an Ubuntu 22.05 host and was able to replicate the issue.
After some digging, I think this is related to Ubuntu's use of dash as the default for /bin/sh on the guest. Are you able to try with bash and see if you have any different result?
Should be able to just set Use dash as the default system shell to no and retry without your patch.
SUMMARY
Almost all Ansible operations appear to use the unresolved path to the Ansible temp directory '~/.ansible/tmp'. However, the ansible.builtin.copy module appears to resolve this path to '/root/.ansible/tmp' when looking for the source file. The underlying problem is that when I examined the filesystem on the VM, it appears that the community.libvirt.libvirt_qemu connection plugin is copying all files in the temp directory to '/~/.ansible/tmp'. The tilde is not being resolved to the homedir of the user and instead ends up in a '/~' directory at the root of the filesystem.
ISSUE TYPE
COMPONENT NAME
community.libvirt.libvirt_qemu connection plugin
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Target OS: Ubuntu 22.04 Server
STEPS TO REPRODUCE
ansible -i local-libvirt-inventory.yml --become all -m copy -a 'src=srcfile dest=/path/to/dest/file'
EXPECTED RESULTS
The local file is copied to the libvirt host.
ACTUAL RESULTS
The file is not copied. When examining the filesystem in the libvirt VM, I found that the directory '/root/.ansible/tmp' doesn't exist. It is located at '/~/.ansible/tmp' instead.
The text was updated successfully, but these errors were encountered: