---
# create the 'edx' virtual environment in /opt so that roles can populate it
- name: common | Install python and pip
  apt: pkg={{item}} install_recommends=yes state=present update_cache=yes
  with_items:
  - python2.7
  - python-pip
  - python2.7-dev
  tags:
  - pre_install
  - install

- name: common | pip install virtualenv
  pip: >
    name=virtualenv 
    state=present
    extra_args="-i {{ PYPI_MIRROR_URL }}"
  tags:
  - venv_base
  - install

- name: common | pip install virtualenvwrapper
  pip: >
    name=virtualenvwrapper 
    state=present
    extra_args="-i {{ PYPI_MIRROR_URL }}"
  tags:
  - venv_base
  - install

- name: common | create edx virtualenv directory
  file: path={{ venv_dir }} owner=ubuntu group=adm mode=2775 state=directory
  tags:
  - venv_base
  - install

- name: common | create the edx virtualenv directory initial contents
  command: /usr/local/bin/virtualenv {{ venv_dir }} --distribute creates=$venv_dir/bin/activate
  tags:
  - venv_base
  - install

- name: common |  pip install gunicorn
  pip: >
    name=gunicorn 
    virtualenv="{{venv_dir}}" 
    state=present
    extra_args="-i {{ PYPI_MIRROR_URL }}"
  tags:
  - gunicorn
  - install