Skip to content

Commit

Permalink
Add a setup script to build the virtual env
Browse files Browse the repository at this point in the history
  • Loading branch information
robolyst committed Oct 28, 2017
1 parent e7df90d commit 8602e59
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Get the directory of this file
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ansible-playbook $DIR/setup/setup.yaml
49 changes: 49 additions & 0 deletions bin/setup/make-virtualenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---

- stat: path=~/.zshrc
register: zshrc_file

- stat: path=~/.virtualenvs/{{ env_name }}
register: venv_path

- name: Find out root path
shell: pwd
register: root_path

- name: install virtualenv
pip: name=virtualenv
# become: True
# become_method: sudo

- name: install virtualenvwrapper
pip: name=virtualenvwrapper
# become: True
# become_method: sudo

- name: add virtualenvwrapper to zsh startup file
when: zshrc_file.stat.exists == True
blockinfile:
dest: ~/.zshrc
marker: "# {mark} virtualenvwrapper ANSIBLE MANAGED BLOCK ###############"
content: |
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
- name: add virtualenvwrapper to .profile file
blockinfile:
dest: ~/.profile
create: yes
marker: "# {mark} virtualenvwrapper ANSIBLE MANAGED BLOCK ###############"
content: |
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
- name: create a virtual environment for the projects
when: venv_path.stat.exists == False
shell: . ~/.profile && mkvirtualenv {{ env_name }}

- name: set the directory for the virtual environment
lineinfile:
dest: ~/.virtualenvs/{{ env_name }}/bin/postactivate
# line: cd {{ root_path.stdout }}
line: cd {{ playbook_dir }}/../../
5 changes: 5 additions & 0 deletions bin/setup/setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: localhost
tasks:

- include: make-virtualenv.yaml env_name=streetview

0 comments on commit 8602e59

Please sign in to comment.