Skip to content

Commit

Permalink
Merge pull request #200 from IKIM-Essen/perf/miniforge
Browse files Browse the repository at this point in the history
perf: update to latest miniforge, since mambaforge is deprecated and miniforge nowadays contains both mamba and conda
  • Loading branch information
mbargull authored Oct 16, 2024
2 parents 97636d7 + 73adef9 commit 6a81156
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
3 changes: 2 additions & 1 deletion ansible/roles/mambaforge/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mambaforge_release: "23.3.1-1"
mambaforge_release: "24.7.1-2"
mamba_home: /opt/mambaforge


# Define mambaforge_user_env_root to override the default environment locations.
# Each user will have "{{ mambaforge_user_env_root }}/$USER" as the default
# environment directory.
Expand Down
60 changes: 40 additions & 20 deletions ansible/roles/mambaforge/tasks/mambaforge.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
---
- name: Create the installation directory
ansible.builtin.file:
path: "{{ mamba_home }}"
state: directory
owner: root
group: root
mode: "0755"
- name: Check the installed version
ansible.builtin.command:
argv:
- "{{ mamba_home }}/condabin/conda"
- --version
changed_when: false
failed_when: false
register: conda_version_cmd

# If this task doesn't run, it leaves mambaforge_same_as_target undefined,
# which means that conda was not detected in the installation directory.
- name: Determine whether the existing installation is already at the target version
ansible.builtin.set_fact:
mambaforge_same_as_target: "{{ conda_version_cmd['stdout'] == 'conda ' ~ mambaforge_conda_version }}"
when:
- conda_version_cmd['rc'] is defined
- conda_version_cmd['rc'] == 0
- conda_version_cmd['stdout'] is defined
- conda_version_cmd['stdout'] != ''

- name: Download the installation script
ansible.builtin.get_url:
Expand All @@ -15,29 +27,37 @@
group: root
mode: "0755"
checksum: "sha256:{{ lookup('url', mambaforge_digest_url) | regex_search('[0-9a-f]{64}') }}"
when: (mambaforge_same_as_target is not defined) or (not mambaforge_same_as_target)

- name: Check the installed version
ansible.builtin.command:
argv:
- "{{ mamba_home }}/condabin/conda"
- --version
changed_when: false
failed_when: false
register: conda_version_cmd
- name: Wipe the existing installation
ansible.builtin.file:
path: "{{ mamba_home }}"
state: absent
when:
- mambaforge_same_as_target is defined
- not mambaforge_same_as_target

- name: Execute the installation script
ansible.builtin.command:
argv:
- /tmp/mambaforge.sh
- -b
- -u
- -p
- "{{ mamba_home }}"
changed_when: true
when:
- conda_version_cmd['rc'] is defined
- conda_version_cmd['stdout'] is defined
- (conda_version_cmd['rc'] != 0) or (conda_version_cmd['stdout'] != 'conda ' ~ mambaforge_conda_version)
when: (mambaforge_same_as_target is not defined) or (not mambaforge_same_as_target)

- name: Remove temporary installer files
ansible.builtin.file:
path: "{{ mambaforge_installer_file }}"
state: absent
loop_control:
loop_var: mambaforge_installer_file
loop:
- /tmp/mambaforge.sh
# TODO: report/fix upstream at conda/constructor
- "{{ mamba_home }}/_conda"
- "{{ mamba_home }}/=2.17"

- name: Create the custom environment root
ansible.builtin.file:
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/mambaforge/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mambaforge_script_name: "Mambaforge-{{ mambaforge_release }}-Linux-{{ ansible_facts['architecture'] }}.sh"
mambaforge_script_name: "Miniforge3-{{ mambaforge_release }}-Linux-{{ ansible_facts['architecture'] }}.sh"
mambaforge_url: "https://github.com/conda-forge/miniforge/releases/download/{{ mambaforge_release }}/{{ mambaforge_script_name }}"
mambaforge_digest_url: "{{ mambaforge_url }}.sha256"
mambaforge_conda_version: "{{ mambaforge_release | regex_search('\\d+\\.\\d+\\.\\d+') }}"

0 comments on commit 6a81156

Please sign in to comment.