简体   繁体   中英

Install python pip modules only for use by 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM