Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

added python-environment playbook #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions python-environment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Python Environment
===================

The playbook creates Virtualenv and install the requirements to Virtualenv.

# Dependencies

None

# Requirements

```
requirements.txt
```

# Example usage
For running the python script, You can use one of 2 ways:

Please use ansible playbook called main.yml, it runs your local, with below:

```
ansible-playbook main.yml
```
5 changes: 5 additions & 0 deletions python-environment/install_requirements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
source venv/bin/activate
pip install -r ./requirements.txt
deactivate
$@
25 changes: 25 additions & 0 deletions python-environment/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
#The playbook creates Virtualenv and install the requirements to Virtualenv.
- name: Create Environment
hosts: 127.0.0.1

tasks:
- name: Manually create the initial virtualenv
command: virtualenv -p python3 venv

- name: Activate Virtualenv
shell: source "./venv"
creates="./venv/bin/activate"

- name: Check that the requirements.txt exists
stat:
path: "./requirements.txt"
register: stat_result

- name: Give permission to run install_requirements.sh
command: Chmod u+x install_requirements.sh
when: stat_result.stat.exists == True

- name: Run the install_requirements.sh to install requirements
shell: bash ./install_requirements.sh
when: stat_result.stat.exists == True
7 changes: 7 additions & 0 deletions python-environment/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#This section should include the requirements you need as follows.
#six==1.11.0
#requests==2.19.1
#decorator==4.3.0
#validators==0.12.2
#PyYAML==4.2b4
#dict2xml==1.6