ansible-roles/conda/tasks/main.yml

44 lines
2.0 KiB
YAML
Raw Normal View History

---
- 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 }} ; 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 }}
environment:
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
args:
creates: '{{ conda_install_prefix }}/envs/{{ item.env_name }}'
executable: /bin/bash
with_items: '{{ conda_env_pkgs }}'
- name: Install additional packages and libraries inside the conda environment
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 }}
environment:
PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}'
args:
executable: /bin/bash
creates: '{{ conda_install_prefix }}/envs/{{ item.env_name }}/.{{ item.pkg }}'
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
tags: [ 'python', 'conda', 'conda_env' ]