Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: update to latest miniforge, since mambaforge is deprecated and miniforge nowadays contains both mamba and conda #200

Merged
merged 5 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
mbargull marked this conversation as resolved.
Show resolved Hide resolved
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+') }}"