Closed insanitywholesale closed 2 weeks ago
Hey @insanitywholesale,
If I understand correctly, are you executing the Ansible modules from a localhost (or any other host that is not a Proxmox host) and connecting to remote Proxmox hosts to modify local images?
Could you please share the Python and Ansible versions that you are using?
I have a Proxmox 8.2.2 host which I can also attempt to run a similar flow to yours.
I accidentally deleted the comment...
@insanitywholesale, I was able to reproduce it on Proxmox 8.2.2.
The root cause is that there is no python executable by default in Debian 11 and onwards:
# apt-cache show python-is-python3
Package: python-is-python3
Source: what-is-python (13)
Version: 3.11.1-3
Installed-Size: 15
Maintainer: Matthias Klose <doko@debian.org>
Architecture: all
Replaces: python, python-dev-is-python3 (<< 3.11.1-2), python-is-python2, python-is-python2-but-deprecated, python-minimal
Depends: python3
Breaks: python, python-dev-is-python3 (<< 3.11.1-2), python-is-python2, python-is-python2-but-deprecated, python-minimal
Description-en: symlinks /usr/bin/python to python3
Starting with the Debian 11 (bullseye) and Ubuntu 20.04 LTS (focal)
releases, all python packages use explicit python3 or python2
interpreter and do not use unversioned /usr/bin/python at all. Some
third-party code is now predominantly python3 based, yet may use
/usr/bin/python.
.
This is a convenience package which ships a symlink to point
the /usr/bin/python interpreter at the current default python3. It may
improve compatibility with other modern systems, whilst breaking some
obsolete or 3rd-party software.
.
No packages may declare dependencies on this package.
# /usr/bin/env python
/usr/bin/env: ‘python’: No such file or directory
A temporary workaround without modifying the code can be either to create a symlink that points to python3 or install the meta package python-is-python3.
# ls -l $(which python)
lrwxrwxrwx 1 root root 7 Jan 8 2023 /usr/bin/python -> python3
# Before `python` symlink
ansible -i inventory moxxi05 -m vkhitrin.libguestfs.guestfs_command -a "image=/tmp/vm.qcow2 shell='cat /etc/os-release'"
moxxi01 | FAILED! => {
"changed": false,
"module_stderr": "Shared connection to moxxi015closed.\r\n",
"module_stdout": "/usr/bin/env: ‘python’: No such file or directory\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 127
}
# After symlink
ansible -i inventory moxxi05 -m vkhitrin.libguestfs.guestfs_command -a "image=/tmp/vm.qcow2 shell='cat /etc/os-release'"
moxxi05 | FAILED! => {
"changed": false,
"msg": "libguestfs Python bindings are required for this module"
}
Thanks for raising this, I will sort it out!
I normally use the modules in the collection to edit a debian cloud image and prepare it so it can be used in a VM template inside proxmox. After upgrading from proxmox 7 (based on debian 11) to proxmox 8 (based on debian 12) I started getting the following errors:
At first, I tried setting
interpreter_python = auto
and theninterpreter_python = auto_legacy
but the error message was the same. Next, I tried hardcodingansible_python_interpreter: /usr/bin/python
insideinventory/group_vars/all.yml
but that didn't fix the problem either and the error message stayed the same.I did a quick test and removed the line
#!/usr/bin/env python
from the files inside~/.ansible/collections/ansible_collections/vkhitrin/libguestfs/plugins
and then everything worked as expected. I'm not sure if that is an okay solution so I didn't open a PR with that but I wanted to mention it here.