-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pipx alternative for deps installation #1797
base: dev
Are you sure you want to change the base?
Conversation
Or, if you can't use pip, e.g. when you are on Ubuntu/Debian: | ||
|
||
```bash | ||
pipx runpip ansible install -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements.txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dxmann73 This only installs these dependencies in the isolated virtual environment ansible
, but how do we call these dependencies when we run the script? Can you describe it here? Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did this actually to work around an issue I had working with the Azure collection on my machine (Ubuntu)
First, following https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pipx
sudo apt install pipx
pipx ensurepath
source ~/.bashrc
pipx install --include-deps ansible
With ansible --version
showing it was correctly installed, following https://galaxy.ansible.com/ui/repo/published/azure/azcollection/docs/ I did
ansible-galaxy collection list | grep azure
and saw it was showing up 2x times. If it hadn't been there I would have done (and tried)
ansible-galaxy collection install azure.azcollection --force
But that didn't change much. Because when trying to work with the Azure collection (as user traefik-vm-adm), I got the following error
ansible localhost -m azure.azcollection.azure_rm_resourcegroup -a "name=foo location=swedencentral"
[WARNING]: No inventory was parsed, only implicit localhost is available
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'azure.mgmt'
localhost | FAILED! => {
"changed": false,
"msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on staging-traefik-vm's Python /home/traefik-vm-adm/.local/share/pipx/venvs/ansible/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"
}
To resolve the error, I tried to pipx inject ansible azure
which failed with a message saying the azure module is deprecated starting with version 5.0.0
So what I did was install the dependencies
pipx runpip ansible install -r ~/.ansible/collections/ansible_collections/azure/azcollection/requirements.txt
and make sure the azure package was there with
ll ~/.local/share/pipx/venvs/ansible/lib/python3.12/site-packages | grep azure
I don't remember exactly if it worked then and there, I may have injected azure v4 as well using
pipx inject ansible azure==4.0.0
Being new to Python it took a considerable amount of time to actually figure all this out to make it work. So I figured at least the pipx runpip part should go into the docs.
Cheers
Dave
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: Many docs say to install stuff just using pip. Ubuntu does not have pip and when you try to install anything with it, it will complain that it will break the system if you do so, talking about managed environments or somesuch and being kinda vague about what the options are. So I feel like more docs should actually mention that.
SUMMARY
After many struggles to get the azure collection installed on Ubuntu, I have finally figured out how to use pipx. It has helped me a lot and I'd llike to add it to the docs.
ISSUE TYPE