Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install python pip modules only for use by Ansible

Tags:

python

ansible

I am using Ansible from a pipeline agent, to configure Ubuntu VMs and I would like to use the azure_rm_storageblob and mssql_script module directly on the Ubuntu VM that I am configuring. I had some issues running this, because the packaging module was not installed on the hosts.

Is there a way to install the pip modules only for use when I run Ansible (maybe a virtual environment), as I don't want to mess with the pip modules that are installed on the server for other purposes.

If this is done using something like a python virtual env, how do I make sure that this is used when I connect to the VM using Ansible?

like image 664
Josh Wright Avatar asked Sep 11 '26 00:09

Josh Wright


1 Answers

You have to use virtual environments to solve that problem (link to the python doc)

First you create the environment with :

python -m venv venv

Then depending on your OS, you have to activate you virtual environment, on Unix you can do :

source venv/bin/activate

The name of you virtual env should be written in your terminal, at that point you know you are using it and not the default python env.

like image 115
FairPluto Avatar answered Sep 12 '26 15:09

FairPluto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!