---
# tasks file for ansible-sdkman

- name: Install SDKMAN
  include_tasks: install.yml

- block:
    - name: Run SDKMAN tasks
      include_tasks: sdkman.yml

    - name: Persist additional SDKMAN environment variables
      include_tasks: persist_env.yml
      loop:
        - .bash_profile
        - .profile
        - .bashrc
        - .zshrc
      loop_control:
        loop_var: sdkman_profile
  environment:
    SDKMAN_DIR: '{{ sdkman_dir }}'
    SDKMAN_OFFLINE_MODE: 'false'
  become: '{{ sdkman_user != ansible_user_id }}'
  become_user: '{{ sdkman_user }}'

---
# tasks file for ansible-sdkman

- name: Install SDKMAN
  include_tasks: install.yml

- block:
    - name: Run SDKMAN tasks
      include_tasks: sdkman.yml

    - name: Persist additional SDKMAN environment variables
      include_tasks: persist_env.yml
      loop:
        - .bash_profile
        - .profile
        - .bashrc
        - .zshrc
      loop_control:
        loop_var: sdkman_profile
  environment:
    SDKMAN_DIR: '{{ sdkman_dir }}'
    SDKMAN_OFFLINE_MODE: 'false'
  become: '{{ sdkman_user != ansible_user_id }}'
  become_user: '{{ sdkman_user }}'

- name: Update alternatives
  alternatives:
    name: "{{ item.name }}"
    path: "{{ sdkman_dir }}/candidates/{{ item.candidate }}/current/bin/{{ item.name }}"
    link: "{{ item.link }}"
  loop: "{{ sdkman_update_alternatives }}"
  become: yes
  tags:
    - sdkman_privilege

Implement task to update alternatives
Implement task to update alternatives
