fix resolve tilde in file paths (fixes #161) #162
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
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 assumptions 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.
ISSUE TYPE
COMPONENT NAME
community.libvirt.libvirt_qemu connection plugin
ADDITIONAL INFORMATION
I've tested this patch with playbooks that use many different Ansible modules and it seems to work in all the ones I tested, including the copy module that was having issues in #161.