forked from ISTI-ansible-roles/ansible-roles
conda: Add tasks that install additional packages inside a conda environment. Add python-env as role dependency.
This commit is contained in:
parent
6c11ced0c7
commit
73cb1d655c
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
# http://conda.pydata.org/miniconda.html
|
||||
conda_ver: 2
|
||||
conda_installer_file: 'Miniconda{{ conda_ver }}-latest-Linux-x86_64.sh'
|
||||
conda_url: 'https://repo.continuum.io/miniconda/{{ conda_installer_file }}'
|
||||
conda_install_prefix: '/srv/conda{{ conda_ver }}'
|
||||
# Change it to an unprivileged user
|
||||
conda_user: root
|
||||
|
||||
#conda_environments:
|
||||
# - { name: '', opts: '' }
|
||||
|
||||
#conda_env_pkgs:
|
||||
# - { conda_prefix: '{{ conda_install_prefix }}', pkg: '', repo_list: '' }
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- role: '../../library/roles/python-env'
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
- block:
|
||||
- name: Find the user home directory path
|
||||
getent: database=passwd key={{ conda_user }} split=":"
|
||||
|
||||
- name: Create a downloads directory if does not exist
|
||||
file: dest={{ getent_passwd[conda_user][4] }}/downloads state=directory
|
||||
|
||||
- name: Download the conda installer
|
||||
get_url: url={{ conda_url }} dest={{ getent_passwd[conda_user][4] }}/downloads mode=0744
|
||||
|
||||
- name: Run the conda installer
|
||||
command: '{{ getent_passwd[conda_user][4] }}/downloads/{{ conda_installer_file }} -f -b -p {{ conda_install_prefix }}'
|
||||
args:
|
||||
creates: '{{ conda_install_prefix }}/bin/conda'
|
||||
|
||||
become: True
|
||||
become_user: '{{ conda_user }}'
|
||||
tags: [ 'python', 'conda' ]
|
||||
|
||||
- block:
|
||||
- name: Create a conda environment
|
||||
shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; conda create -y -n {{ item.name }} {{ item.opts }}
|
||||
environment:
|
||||
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
|
||||
args:
|
||||
creates: '{{ conda_install_prefix }}/envs/{{ item.name }}'
|
||||
with_items: '{{ conda_environments }}'
|
||||
|
||||
- name: Install additional packages and libraries inside the conda environment
|
||||
shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; conda install -y {{ item.repo_list }} {{ item.pkg }} ; touch {{ conda_install_prefix }}/.{{ item.pkg }}
|
||||
environment:
|
||||
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
|
||||
args:
|
||||
creates: '{{ conda_install_prefix }}/.{{ item.pkg }}'
|
||||
with_items: '{{ conda_env_pkgs }}'
|
||||
when: conda_env_pkgs is defined
|
||||
|
||||
become: True
|
||||
become_user: '{{ conda_user }}'
|
||||
when: conda_environments is defined
|
||||
tags: [ 'python', 'conda', 'conda_env' ]
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
py_env_install: True
|
Loading…
Reference in New Issue