Open bix6 opened 3 years ago
Hi, I ran into the same problem today. I overlooked the fact that ansible is running on the remote host, and that is where the requirements should be installed. So either add a task to install the requirements remotely or use delegate_to to run the task locally.
On top of that, could you turn "Check the requirements" into something more verbose? Maybe the actual ImportError?
We have a very recent breakage on CentOS 8 (Stream), and I don't know what causes it. The requirements used to be fine just a couple of weeks ago.
@dtantsur hi, thanks for reporting this!
You installed libvirt-python via pip3. Could you please try run your playbook with the -e "ansible_python_interpreter=/path/to/your/python3/interpreter"
argument? (Python 3 support)
Looks like the module uses python2 and doesn't see python3 libs.
I'm looking forward to your feedback
@Andersson007 that's what we're doing. We're well past Python 3 issues at this point (we switched more than a year ago).
This is a workaround we have to provide: https://review.opendev.org/c/openstack/bifrost/+/800214/3/playbooks/roles/bifrost-create-vm-nodes/tasks/prepare_libvirt.yml. It essentially prevents pip
from using libvirt
wheels and forces a source installation. I must admit, I have no clue how and why it works, especially since this issue is not trivial to reproduce (we hit it in the CI workers, but not locally).
@dtantsur thank you for the feedback and the workaround! I pinged the folks in https://github.com/ansible-collections/community.libvirt/pull/77#issuecomment-882513098. Maybe they have some ideas and will respond. We should definitely improve this part of the doc.
I would caution everyone that mixing your system packages and packages from pypi is not a good idea. Things from pypi should be installed in a user's home directory (not root) using --user or should go into a venv.
libvirt-python is a bit of a pain because it has host OS binary bindings, so usually it is best to install it via the distribution packaging (a package called python-libvirt or something like that). This package must be on the target host where the virtual machines will be run or where the inventory source is.
If you want to use it in a venv, then there are two ways I've done this before:
--system-site-packages
so that the system libraries are put into the venv.Be warned that option 1 above is simpler, but will bring in more libraries. Option 2 is more complex, but also more surgical.
Could anyone try the way suggested by @odyssey4me and give feedback? If we had a step-by-step guide, we could create INSTALLATION file and link to it from README (or put the guide directly to README if it's not long).
I would caution everyone that mixing your system packages and packages from pypi is not a good idea. Things from pypi should be installed in a user's home directory (not root) using --user or should go into a venv.
Yep, except that python-apt/python-dnf are not distributed via pypi, so to use ansible with venv you need to use --system-site-packages
. Which could contribute to our issues :(
(Off topic: there's the Quick-start guide there which can help people who want to clarify the installation process but have no experience in contributing to Ansible and how to submit a pull request. All related to testing in the guide is irrelevant here)
SUMMARY
Please clarify install instructions and requirements. I am struggling to setup this module and cannot find clear documentation anywhere. I am attempting to hack multiple guides together and still not having success. I have tried both python2 and python3 now.
Here is the current flow I am attempting. It's still not working but I don't know where to go from here.
This is the error I have now in my playbook (I have read many pages discussing this error):
ISSUE TYPE
COMPONENT NAME
community.libvirt.virt
ANSIBLE VERSION