Skip to content

Commit

Permalink
Add custom virtualenvironment name for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
meg-codes committed Jan 2, 2019
1 parent 23cd687 commit 4deabbd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions filter_plugins/project_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from ansible.module_utils._text import to_text


class FilterModule(object):

def filters(self):
return {
'project_name': self.project_name
}

def project_name(self, arg):
"""Extract name of a project from a GitHub reference
of the form owner/repo.
"""
return to_text(arg.split('/')[1])
2 changes: 2 additions & 0 deletions roles/build_virtualenv/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
state: latest
virtualenv: "{{ deploy }}/env"
virtualenv_site_packages: yes
- name: Set name of venv to project-name-short-hash-version
command: "virtualenv {{ deploy }}/env --prompt '({{ repo | project_name }}-{{ short_hash }}-{{ version }}) '"
- name: Set perms
file:
path: "{{ deploy }}/env"
Expand Down

0 comments on commit 4deabbd

Please sign in to comment.