Migrate the role

This commit is contained in:
Alexander Gorelyshev
2026-05-19 15:05:14 +04:00
parent fd6e2517a3
commit f706aa0f38
13 changed files with 336 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
---
- name: "Get contents of the manifest file"
register: miniforge_manifest_content
ansible.builtin.slurp:
src: "{{ miniforge_homedir }}/{{ file }}"
# Since the file can be named whatever, we need to extract the environment name
# as that is what the actual environment folder name will be
- name: "Extract enviroment name from manifest file"
ansible.builtin.set_fact:
miniforge_env_name: '{{ (miniforge_manifest_content.content | b64decode | from_yaml).name }}'
- name: "Display the extracted environment name"
ansible.builtin.debug:
msg: "{{ miniforge_env_name }}"
- name: "Create environment: {{ miniforge_env_name }}"
become: true
become_user: "{{ user.name }}"
ansible.builtin.shell:
cmd: "{{ miniforge_homedir }}/miniforge3/bin/mamba env create -f {{ miniforge_homedir }}/{{ file }}"
executable: /bin/bash
# ensures that the task runs only when the environment doesn't exist
creates: "{{ miniforge_homedir }}/miniforge3/envs/{{ miniforge_env_name }}"