initial commit
This commit is contained in:
42
roles/shell/tasks/install_starship.yml
Normal file
42
roles/shell/tasks/install_starship.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
---
|
||||
# Install Starship prompt (https://starship.rs/)
|
||||
|
||||
- name: Determine target user
|
||||
ansible.builtin.set_fact:
|
||||
shell_user: "{{ shell_user | default( lookup('env','USER') ) }}"
|
||||
|
||||
- name: Detect platform
|
||||
ansible.builtin.set_fact:
|
||||
is_macos: "{{ ansible_facts['os_family'] == 'Darwin' }}"
|
||||
|
||||
- name: Check if starship is already installed
|
||||
ansible.builtin.command: which starship
|
||||
register: starship_check
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Install Starship on macOS using Homebrew
|
||||
community.general.homebrew:
|
||||
name: starship
|
||||
state: present
|
||||
when: is_macos and starship_check.rc != 0
|
||||
become: true
|
||||
become_user: "{{ shell_user }}"
|
||||
|
||||
- name: Install Starship on Linux using official installer
|
||||
ansible.builtin.shell: |
|
||||
curl -fsSL https://starship.rs/install.sh | sh -s -- -y
|
||||
args:
|
||||
executable: /bin/bash
|
||||
when: not is_macos and starship_check.rc != 0
|
||||
become: true
|
||||
|
||||
- name: Ensure starship is in PATH
|
||||
ansible.builtin.command: which starship
|
||||
register: starship_check_after
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
|
||||
- name: Print starship path
|
||||
ansible.builtin.debug:
|
||||
msg: "starship path: {{ starship_check_after.stdout }}"
|
||||
Reference in New Issue
Block a user