2017-12-22 13:37:49 +01:00
|
|
|
---
|
|
|
|
- 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
|
2018-04-18 18:17:46 +02:00
|
|
|
shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; mkdir -p {{ conda_user_home }}/.conda/pkgs/ ; chown -R {{ conda_user }} {{ conda_user_home }}/.conda ; {{ conda_install_prefix }}/bin/conda create -y -n {{ item.env_name }} {{ item.env_opts }} || exit 0
|
2018-01-05 13:00:04 +01:00
|
|
|
environment:
|
|
|
|
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
|
2017-12-22 13:37:49 +01:00
|
|
|
args:
|
2018-01-05 12:43:35 +01:00
|
|
|
creates: '{{ conda_install_prefix }}/envs/{{ item.env_name }}'
|
2018-01-05 12:58:17 +01:00
|
|
|
executable: /bin/bash
|
2018-01-05 12:43:35 +01:00
|
|
|
with_items: '{{ conda_env_pkgs }}'
|
2017-12-22 13:37:49 +01:00
|
|
|
|
|
|
|
- name: Install additional packages and libraries inside the conda environment
|
2018-01-05 14:21:59 +01:00
|
|
|
shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; source {{ conda_install_prefix }}/bin/activate {{ item.env_name }} ; {{ conda_install_prefix }}/bin/conda install -y {{ item.repo_list }} {{ item.pkg }} ; touch {{ conda_install_prefix }}/envs/{{ item.env_name }}/.{{ item.pkg }}
|
2018-01-05 13:00:04 +01:00
|
|
|
environment:
|
|
|
|
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
|
2017-12-22 13:37:49 +01:00
|
|
|
args:
|
2018-01-05 12:58:17 +01:00
|
|
|
executable: /bin/bash
|
2018-01-05 12:43:35 +01:00
|
|
|
creates: '{{ conda_install_prefix }}/envs/{{ item.env_name }}/.{{ item.pkg }}'
|
2017-12-22 13:37:49 +01:00
|
|
|
with_items: '{{ conda_env_pkgs }}'
|
|
|
|
|
|
|
|
become: True
|
|
|
|
become_user: '{{ conda_user }}'
|
2018-01-05 12:52:14 +01:00
|
|
|
when: conda_env_pkgs is defined
|
2017-12-22 13:37:49 +01:00
|
|
|
tags: [ 'python', 'conda', 'conda_env' ]
|