diff options
| author | Ahmed Abdelhalim <[email protected]> | 2026-03-04 00:47:09 +0100 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2026-03-04 00:49:46 +0100 |
| commit | 570555cf2d464078190240df724ca4f148c72b48 (patch) | |
| tree | 44f50edc747c8f84cba74a392df6110981789617 | |
| parent | cdbb782ab1aa2c337fcfeca0693ac8e22582d186 (diff) | |
Refactor language roles to use mise and install multiple version support
| -rw-r--r-- | group_vars/all.yml | bin | 4565 -> 4454 bytes | |||
| -rw-r--r-- | host_vars/archlinux.local.yml | bin | 1209 -> 1245 bytes | |||
| -rw-r--r-- | host_vars/archlinux.local.yml.example | 11 | ||||
| -rw-r--r-- | host_vars/mac.local.yml | bin | 1037 -> 1073 bytes | |||
| -rw-r--r-- | host_vars/mac.local.yml.example | 9 | ||||
| -rw-r--r-- | roles/go/defaults/main.yml | 3 | ||||
| -rw-r--r-- | roles/go/meta/argument_specs.yml | 11 | ||||
| -rw-r--r-- | roles/go/meta/main.yml | 2 | ||||
| -rw-r--r-- | roles/go/tasks/main.yml | 13 | ||||
| -rw-r--r-- | roles/nodejs/meta/argument_specs.yml | 1 | ||||
| -rw-r--r-- | roles/nodejs/meta/main.yml | 5 | ||||
| -rw-r--r-- | roles/nodejs/tasks/main.yml | 4 | ||||
| -rw-r--r-- | roles/python/defaults/main.yml | 4 | ||||
| -rw-r--r-- | roles/python/meta/argument_specs.yml | 12 | ||||
| -rw-r--r-- | roles/python/meta/main.yml | 5 | ||||
| -rw-r--r-- | roles/python/tasks/main.yml | 64 | ||||
| -rw-r--r-- | roles/python/vars/archlinux.yml | 2 | ||||
| -rw-r--r-- | roles/python/vars/debian.yml | 2 | ||||
| -rw-r--r-- | roles/rust/defaults/main.yml | 3 | ||||
| -rw-r--r-- | roles/rust/meta/argument_specs.yml | 13 | ||||
| -rw-r--r-- | roles/rust/meta/main.yml | 5 | ||||
| -rw-r--r-- | roles/rust/tasks/main.yml | 13 |
22 files changed, 89 insertions, 93 deletions
diff --git a/group_vars/all.yml b/group_vars/all.yml Binary files differindex 70232d76..55b74c37 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml diff --git a/host_vars/archlinux.local.yml b/host_vars/archlinux.local.yml Binary files differindex 111991e3..f4d0568e 100644 --- a/host_vars/archlinux.local.yml +++ b/host_vars/archlinux.local.yml diff --git a/host_vars/archlinux.local.yml.example b/host_vars/archlinux.local.yml.example index f6f4ce5e..e8bad3f4 100644 --- a/host_vars/archlinux.local.yml.example +++ b/host_vars/archlinux.local.yml.example @@ -7,10 +7,19 @@ network_ipv6_address: "fd5c:fd8b:2b8c::201/64" network_ipv6_gateway: "fd5c:fd8b:2b8c::254" network_ipv6_dns: "fd5c:fd8b:2b8c::254" -go_version: "1.25.3" +go_versions: + - "latest" + - "1.25.3" +rust_versions: + - "latest" + - "1.83.0" +nodejs_versions: + - "lts" + - "22.22.0" python_versions: - "3.13.7" - "3.12.11" + ansible_core_version: "2.18.7" molecule_version: "25.7.0" diff --git a/host_vars/mac.local.yml b/host_vars/mac.local.yml Binary files differindex 8d0366f4..bfb759f7 100644 --- a/host_vars/mac.local.yml +++ b/host_vars/mac.local.yml diff --git a/host_vars/mac.local.yml.example b/host_vars/mac.local.yml.example index 22cce63b..c301010c 100644 --- a/host_vars/mac.local.yml.example +++ b/host_vars/mac.local.yml.example @@ -7,6 +7,15 @@ network_ipv6_address: "fd5c:fd8b:2b8c::200/64" network_ipv6_gateway: "fd5c:fd8b:2b8c::254" network_ipv6_dns: "fd5c:fd8b:2b8c::254" +go_versions: + - "latest" + - "1.25.3" +rust_versions: + - "latest" + - "1.83.0" +nodejs_versions: + - "lts" + - "22.22.0" python_versions: - "3.13.7" - "3.12.11" diff --git a/roles/go/defaults/main.yml b/roles/go/defaults/main.yml index 67bb55f2..6d8217b9 100644 --- a/roles/go/defaults/main.yml +++ b/roles/go/defaults/main.yml @@ -1,2 +1,3 @@ --- -go_version: "latest" +go_versions: + - "latest" diff --git a/roles/go/meta/argument_specs.yml b/roles/go/meta/argument_specs.yml index 3e518135..803fa6ea 100644 --- a/roles/go/meta/argument_specs.yml +++ b/roles/go/meta/argument_specs.yml @@ -1,10 +1,9 @@ --- argument_specs: main: - short_description: "Install Go on Linux distributions" - description: "Install Go on Linux distributions" options: - go_version: - type: "str" - description: "Default go version to install" - default: "latest" + go_versions: + type: "list" + description: "Go versions to install via mise (e.g. 'latest', '1.24')" + elements: "str" + default: ["latest"] diff --git a/roles/go/meta/main.yml b/roles/go/meta/main.yml index 9990d138..946d0801 100644 --- a/roles/go/meta/main.yml +++ b/roles/go/meta/main.yml @@ -3,7 +3,7 @@ dependencies: - role: "mise" galaxy_info: author: "a14m" - description: "Install Go via mise on Linux distributions" + description: "Install Go (versions) via mise on Linux distributions" license: "MIT" min_ansible_version: "2.18" platforms: diff --git a/roles/go/tasks/main.yml b/roles/go/tasks/main.yml index fbf6e688..47fec265 100644 --- a/roles/go/tasks/main.yml +++ b/roles/go/tasks/main.yml @@ -1,16 +1,17 @@ --- -- name: "Check installed go version" +- name: "Check installed go versions" ansible.builtin.command: - cmd: "mise current go" - register: go_current_version + cmd: "mise ls go" + register: go_installed_versions changed_when: false failed_when: false -- name: "Install go {{ go_version }}" +- name: "Install go {{ item }}" ansible.builtin.command: - cmd: "mise use --global go@{{ go_version }}" + cmd: "mise use --global go@{{ item }}" changed_when: true - when: go_version not in go_current_version.stdout + when: item not in go_installed_versions.stdout + loop: "{{ go_versions }}" - name: "Add Go bin to shell profile" ansible.builtin.blockinfile: diff --git a/roles/nodejs/meta/argument_specs.yml b/roles/nodejs/meta/argument_specs.yml index fbb6527d..bcfee791 100644 --- a/roles/nodejs/meta/argument_specs.yml +++ b/roles/nodejs/meta/argument_specs.yml @@ -1,7 +1,6 @@ --- argument_specs: main: - description: "Install nodejs versions via mise on Linux distributions" options: nodejs_versions: type: "list" diff --git a/roles/nodejs/meta/main.yml b/roles/nodejs/meta/main.yml index f76250dc..b75e6a41 100644 --- a/roles/nodejs/meta/main.yml +++ b/roles/nodejs/meta/main.yml @@ -1,10 +1,9 @@ --- dependencies: - - role: "bash" - - role: "curl" + - role: "mise" galaxy_info: author: "a14m" - description: "Install nvm and nodejs (versions) on Linux distributions" + description: "Install nodejs (versions) via mise on Linux distributions" license: "MIT" min_ansible_version: "2.18" platforms: diff --git a/roles/nodejs/tasks/main.yml b/roles/nodejs/tasks/main.yml index 453fbaa5..c5fc2635 100644 --- a/roles/nodejs/tasks/main.yml +++ b/roles/nodejs/tasks/main.yml @@ -2,7 +2,7 @@ - name: "Check installed node versions" ansible.builtin.command: cmd: "mise ls node" - register: node_installed_versions + register: nodejs_installed_versions changed_when: false failed_when: false @@ -10,5 +10,5 @@ ansible.builtin.command: cmd: "mise use --global node@{{ item }}" changed_when: true - when: item not in node_installed_versions.stdout + when: item not in nodejs_installed_versions.stdout loop: "{{ nodejs_versions }}" diff --git a/roles/python/defaults/main.yml b/roles/python/defaults/main.yml index c6cfa5a4..2e43307e 100644 --- a/roles/python/defaults/main.yml +++ b/roles/python/defaults/main.yml @@ -1,2 +1,4 @@ --- -python_versions: [] +python_versions: + - "latest" +python_uv_version: "latest" diff --git a/roles/python/meta/argument_specs.yml b/roles/python/meta/argument_specs.yml index d0d29d41..f087f142 100644 --- a/roles/python/meta/argument_specs.yml +++ b/roles/python/meta/argument_specs.yml @@ -1,11 +1,15 @@ --- argument_specs: main: - short_description: "Install uv, pipx and python (versions) on Linux distributions" - description: "Install uv, pipx and python (versions) on Linux distributions" + short_description: "Install Python versions on Linux distributions" + description: "Install Python versions on Linux distributions" options: python_versions: type: "list" - description: "The extra python versions to install (system is used by default when available)" + description: "Python versions to install via mise (e.g. 'latest', '3.13')" elements: "str" - default: [] + default: ["latest"] + python_uv_version: + type: "str" + description: "uv version to install via mise" + default: "latest" diff --git a/roles/python/meta/main.yml b/roles/python/meta/main.yml index bdd71088..d90de25e 100644 --- a/roles/python/meta/main.yml +++ b/roles/python/meta/main.yml @@ -1,10 +1,9 @@ --- dependencies: - - role: "bash" - - role: "curl" + - role: "mise" galaxy_info: author: "a14m" - description: "Install uv and python (versions) on Linux distributions" + description: "Install uv and python (versions) via mise on Linux distributions" license: "MIT" min_ansible_version: "2.18" platforms: diff --git a/roles/python/tasks/main.yml b/roles/python/tasks/main.yml index e721e931..66cbda67 100644 --- a/roles/python/tasks/main.yml +++ b/roles/python/tasks/main.yml @@ -1,49 +1,27 @@ --- -- name: "Include OS-specific variables" - ansible.builtin.include_vars: "{{ ansible_facts['os_family'] | lower }}.yml" - -- name: "Check if uv binary exists" - ansible.builtin.stat: - path: "{{ ansible_facts['env']['HOME'] }}/.local/bin/uv" - register: python_uv_binary - -- name: "Download uv installer" - ansible.builtin.get_url: - url: "https://astral.sh/uv/install.sh" - dest: "/tmp/install_uv.sh" - mode: "0755" - when: not python_uv_binary.stat.exists - -- name: "Run uv installer" +- name: "Check installed python versions" ansible.builtin.command: - cmd: "/tmp/install_uv.sh" - args: - creates: "{{ ansible_facts['env']['HOME'] }}/.local/bin/uv" - when: not python_uv_binary.stat.exists + cmd: "mise ls python" + register: python_installed_versions + changed_when: false + failed_when: false -- name: "Symlink uv to /usr/local/bin" - become: true - ansible.builtin.file: - src: "{{ ansible_facts['env']['HOME'] }}/.local/bin/uv" - dest: "/usr/local/bin/uv" - state: "link" +- name: "Install python {{ item }}" + ansible.builtin.command: + cmd: "mise use --global python@{{ item }}" + changed_when: true + when: item not in python_installed_versions.stdout + loop: "{{ python_versions }}" -- name: "Add uv to shell profile" - ansible.builtin.blockinfile: - path: "{{ ansible_facts['env']['HOME'] }}/.bashrc" - state: "present" - prepend_newline: true - append_newline: true - marker: "# ==== {mark} ANSIBLE PATH CONFIG" - block: | - if [ -d "$HOME/.local/bin" ]; then - export PATH="$HOME/.local/bin:$PATH" - fi +- name: "Check installed uv version" + ansible.builtin.command: + cmd: "mise ls uv" + register: python_uv_installed_version + changed_when: false + failed_when: false -- name: "Install python versions" +- name: "Install uv {{ python_uv_version }}" ansible.builtin.command: - cmd: "uv python install {{ item }}" - register: python_install_result - changed_when: "'already installed' not in python_install_result.stderr" - loop: "{{ python_versions }}" - when: python_versions | length > 0 + cmd: "mise use --global uv@{{ python_uv_version }}" + changed_when: true + when: uv_version not in python_uv_installed_version.stdout diff --git a/roles/python/vars/archlinux.yml b/roles/python/vars/archlinux.yml deleted file mode 100644 index 49cedb43..00000000 --- a/roles/python/vars/archlinux.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -python_packaging: "python-packaging" diff --git a/roles/python/vars/debian.yml b/roles/python/vars/debian.yml deleted file mode 100644 index 2fb30364..00000000 --- a/roles/python/vars/debian.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -python_packaging: "python3-packaging" diff --git a/roles/rust/defaults/main.yml b/roles/rust/defaults/main.yml index a23ee6dc..7cb39ef2 100644 --- a/roles/rust/defaults/main.yml +++ b/roles/rust/defaults/main.yml @@ -1,3 +1,4 @@ --- -rust_toolchain: "stable" +rust_versions: + - "stable" rust_components: [] diff --git a/roles/rust/meta/argument_specs.yml b/roles/rust/meta/argument_specs.yml index 93ebc36e..612812b6 100644 --- a/roles/rust/meta/argument_specs.yml +++ b/roles/rust/meta/argument_specs.yml @@ -1,15 +1,14 @@ --- argument_specs: main: - short_description: "Install Rust via rustup on Linux distributions" - description: "Install Rust via rustup on Linux distributions" options: - rust_toolchain: - type: "str" - description: "The Rust toolchain to install (stable, beta, nightly)" - default: "stable" + rust_versions: + type: "list" + description: "Rust versions to install via mise (e.g. 'stable', 'nightly')" + elements: "str" + default: ["stable"] rust_components: type: "list" - description: "Additional rustup components to install" + description: "Rust components to install via rustup (applied to the active toolchain)" elements: "str" default: [] diff --git a/roles/rust/meta/main.yml b/roles/rust/meta/main.yml index 8afa47c1..af2fe6fa 100644 --- a/roles/rust/meta/main.yml +++ b/roles/rust/meta/main.yml @@ -1,10 +1,9 @@ --- dependencies: - - role: "bash" - - role: "curl" + - role: "mise" galaxy_info: author: "a14m" - description: "Install Rust via rustup on Linux distributions" + description: "Install Rust (versions) via mise on Linux distributions" license: "MIT" min_ansible_version: "2.18" platforms: diff --git a/roles/rust/tasks/main.yml b/roles/rust/tasks/main.yml index 4c34eb81..85ebdd95 100644 --- a/roles/rust/tasks/main.yml +++ b/roles/rust/tasks/main.yml @@ -1,16 +1,17 @@ --- -- name: "Check installed rust version" +- name: "Check installed rust versions" ansible.builtin.command: - cmd: "mise current rust" - register: rust_current_version + cmd: "mise ls rust" + register: rust_installed_versions changed_when: false failed_when: false -- name: "Install rust {{ rust_toolchain }}" +- name: "Install rust {{ item }}" ansible.builtin.command: - cmd: "mise use --global rust@{{ rust_toolchain }}" + cmd: "mise use --global rust@{{ item }}" changed_when: true - when: rust_toolchain not in rust_current_version.stdout + when: item not in rust_installed_versions.stdout + loop: "{{ rust_versions }}" - name: "Install rust components" ansible.builtin.command: |
