--- - name: List globally installed npm packages ansible.builtin.command: npm list --global --depth=0 --json register: npm_global_list changed_when: false failed_when: false - name: Install global language servers and formatters ansible.builtin.command: "npm install --global {{ item }}" loop: "{{ npm_global_packages }}" when: item not in ((npm_global_list.stdout | default('{}', true) | from_json).dependencies | default({})) - name: Check for rustup ansible.builtin.stat: path: "{{ user_home }}/.cargo/bin/rustup" become: false register: rustup_binary - name: Download the official rustup installer ansible.builtin.get_url: url: https://sh.rustup.rs dest: /tmp/rustup-init.sh mode: "0755" when: not rustup_binary.stat.exists - name: Install Rust stable with the official rustup installer ansible.builtin.command: argv: - /tmp/rustup-init.sh - -y - --default-toolchain - stable - --profile - default environment: HOME: "{{ user_home }}" become: false when: not rustup_binary.stat.exists - name: Remove the rustup installer ansible.builtin.file: path: /tmp/rustup-init.sh state: absent - name: Check the active Rust toolchain ansible.builtin.command: "{{ user_home }}/.cargo/bin/rustup show active-toolchain" become: false register: active_rust_toolchain changed_when: false failed_when: false - name: Select the Rust stable toolchain ansible.builtin.command: "{{ user_home }}/.cargo/bin/rustup default stable" become: false when: active_rust_toolchain.rc != 0 or not active_rust_toolchain.stdout.startswith('stable-') - name: List installed rustup components ansible.builtin.command: "{{ user_home }}/.cargo/bin/rustup component list --installed" become: false register: installed_rustup_components changed_when: false - name: Install Rust development components ansible.builtin.command: "{{ user_home }}/.cargo/bin/rustup component add {{ item }}" loop: "{{ rustup_components }}" become: false when: installed_rustup_components.stdout_lines | select('match', '^' ~ item ~ '(-|$)') | list | length == 0 - name: Check for StyLua ansible.builtin.stat: path: "{{ user_home }}/.cargo/bin/stylua" become: false register: stylua_binary - name: Install StyLua ansible.builtin.command: "{{ user_home }}/.cargo/bin/cargo install stylua --locked" become: false when: not stylua_binary.stat.exists - name: Check for Starship ansible.builtin.stat: path: "{{ user_home }}/.local/bin/starship" become: false register: starship_binary - name: Download Starship installer script ansible.builtin.get_url: url: https://starship.rs/install.sh dest: /tmp/install_starship.sh mode: '0755' when: not starship_binary.stat.exists - name: Run Starship installer ansible.builtin.command: /tmp/install_starship.sh -y --bin-dir "{{ user_home }}/.local/bin" become: false when: not starship_binary.stat.exists - name: Remove the Starship installer ansible.builtin.file: path: /tmp/install_starship.sh state: absent when: not starship_binary.stat.exists