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-01-05 12:43:35 +01:00
|
|
|
shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; conda create -y -n {{ item.env_name }} {{ item.env_opts }}
|
2017-12-22 13:37:49 +01:00
|
|
|
environment:
|
|
|
|
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
|
|
|
|
args:
|
2018-01-05 12:43:35 +01:00
|
|
|
creates: '{{ conda_install_prefix }}/envs/{{ item.env_name }}'
|
|
|
|
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 12:43:35 +01:00
|
|
|
shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; source {{ conda_install_prefix }}/bin/activate {{ item.env_name }} ; conda install -y {{ item.repo_list }} {{ item.pkg }} ; touch {{ conda_install_prefix }}/envs/{{ item.env_name }}/.{{ item.pkg }}
|
2017-12-22 13:37:49 +01:00
|
|
|
environment:
|
|
|
|
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
|
|
|
|
args:
|
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 }}'
|
|
|
|
when: conda_env_pkgs is defined
|
|
|
|
|
|
|
|
become: True
|
|
|
|
become_user: '{{ conda_user }}'
|
|
|
|
when: conda_environments is defined
|
|
|
|
tags: [ 'python', 'conda', 'conda_env' ]
|