Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mikhail Sobolev
committed
Dec 13, 2014
1 parent
9fe8345
commit a359885
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
This roles allows to create a Python virtual environment. | ||
|
||
The role should be used with the following parameters: | ||
|
||
``venv_user`` | ||
The user under which the virtual environment is created | ||
|
||
``venv_home_dir`` | ||
ansible likes absolute paths in way too many places, the virtual | ||
environment is created in the users' home directory and this is its path | ||
|
||
``venv_name`` | ||
The name of the virtual environment | ||
|
||
``venv_packages`` | ||
packages to be installed using 'pkgng' | ||
|
||
``venv_python_packages`` | ||
Python packages to be installed using 'pip install' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
# This is mostly for pysqlite that needs to find locally installed sqlite3 | ||
# headers and libraries. But it might be needed for other modules as well. | ||
- name: prepare ~/.pydistutils.cfg | ||
ini_file: | ||
dest: "{{ venv_home_dir }}/.pydistutils.cfg" | ||
section: "build_ext" | ||
option: "{{ item.option }}" | ||
value: "{{ item.value }}" | ||
owner: "{{ venv_user }}" | ||
with_items: | ||
- option: include_dirs | ||
value: "/usr/local/include" | ||
- option: library_dirs | ||
value: "/usr/local/lib" | ||
|
||
- name: install system packages | ||
pkgng: | ||
name: "{{item}}" | ||
state: present | ||
with_items: venv_packages | ||
|
||
- name: create the virtual environment | ||
sudo_user: "{{ venv_user }}" | ||
pip: | ||
name: "{{ item }}" | ||
virtualenv: "{{ venv_home_dir }}/{{ venv_name }}" | ||
with_items: venv_python_packages |