Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run python setup.py develop command inside virtualenv using ansible

I want to execute python setup.py develop command inside of virtualenv using ansible. How to do it?

Probably could be something like this:

- name: egg
  shell: "python setup.py develop"

But I need to execute it inside of virtualenv. How can I do it?

like image 787
Roman Dryndik Avatar asked Jun 27 '14 10:06

Roman Dryndik


People also ask

How do I run Ansible in Virtualenv?

Set up virtualenv¶After you install virtualenv, you can create a “virtual environment” to host your local copy of Ansible. This command creates a directory called myansible in your current working directory. This directory contains a copy of Python that will install modules in the myansible directory.

Where is Ansible CFG in Virtualenv?

Home directory. /etc/ansible/ansible. cfg.

Can we use Python in Ansible?

You can use the Ansible Python API to control nodes, you can extend Ansible to respond to various Python events, you can write plugins, and you can plug in inventory data from external data sources. This document gives a basic overview and examples of the Ansible execution and playbook API.

How do I run Ansible in Python 3?

Ansible will automatically detect and use Python 3 on many platforms that ship with it. To explicitly configure a Python 3 interpreter, set the ansible_python_interpreter inventory variable at a group or host level to the location of a Python 3 interpreter, such as /usr/bin/python3.


1 Answers

You could also try chaining commands together.

- name: chained shell command
  shell: "source /path/to/env/bin/activate; python setup.py develop"
like image 124
PaulR Avatar answered Sep 23 '22 03:09

PaulR