From 835df95a15a8499681a36c3c9f002517fde047c1 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 5 Jan 2018 12:43:35 +0100 Subject: [PATCH] conda, dataminer: setup the environment before installing the packages. --- conda/defaults/main.yml | 5 +---- conda/tasks/main.yml | 10 +++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/conda/defaults/main.yml b/conda/defaults/main.yml index 66d42a81..d1a40504 100644 --- a/conda/defaults/main.yml +++ b/conda/defaults/main.yml @@ -7,9 +7,6 @@ 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: '' } +# - { env_name: '', env_opts: '', conda_prefix: '{{ conda_install_prefix }}', pkg: '', repo_list: '' } diff --git a/conda/tasks/main.yml b/conda/tasks/main.yml index 2d9d5e2c..bd6fd18e 100644 --- a/conda/tasks/main.yml +++ b/conda/tasks/main.yml @@ -20,19 +20,19 @@ - block: - name: Create a conda environment - shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; conda create -y -n {{ item.name }} {{ item.opts }} + shell: export PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }} ; 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.name }}' - with_items: '{{ conda_environments }}' + creates: '{{ conda_install_prefix }}/envs/{{ item.env_name }}' + 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 }} ; conda install -y {{ item.repo_list }} {{ item.pkg }} ; touch {{ conda_install_prefix }}/.{{ item.pkg }} + 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 }} environment: PATH: 'PATH={{ conda_install_prefix }}/bin:{{ ansible_env.PATH }}' args: - creates: '{{ conda_install_prefix }}/.{{ item.pkg }}' + creates: '{{ conda_install_prefix }}/envs/{{ item.env_name }}/.{{ item.pkg }}' with_items: '{{ conda_env_pkgs }}' when: conda_env_pkgs is defined