99 lines
2.7 KiB
YAML
99 lines
2.7 KiB
YAML
---
|
|
# Debian / Ubuntu package installation
|
|
# Adds the Fish shell PPA to get 4.x on older Ubuntu releases.
|
|
|
|
- name: Install prerequisites for PPA management
|
|
become: true
|
|
ansible.builtin.apt:
|
|
name:
|
|
- software-properties-common
|
|
- apt-transport-https
|
|
- gnupg
|
|
- curl
|
|
state: present
|
|
update_cache: true
|
|
|
|
# --- Fish PPA (Ubuntu only, needed for 4.x on < 24.10) ---
|
|
|
|
- name: Check current Fish version
|
|
ansible.builtin.command: fish --version
|
|
register: cli_modern_fish_version_check
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Extract Fish version number
|
|
ansible.builtin.set_fact:
|
|
cli_modern_fish_current_ver: >-
|
|
{{ (cli_modern_fish_version_check.stdout
|
|
| default('')
|
|
| regex_search('(\d+\.\d+)', '\1')
|
|
| default([], true))
|
|
| first
|
|
| default('0') }}
|
|
|
|
- name: Add fastfetch PPA
|
|
become: true
|
|
ansible.builtin.apt_repository:
|
|
repo: ppa:zhangsongcui3371/fastfetch
|
|
state: present
|
|
update_cache: true
|
|
|
|
- name: Determine if Fish PPA is needed
|
|
ansible.builtin.set_fact:
|
|
cli_modern_need_fish_ppa: >-
|
|
{{ cli_modern_install_fish and (
|
|
cli_modern_fish_version_check.rc != 0 or
|
|
cli_modern_fish_current_ver is version(cli_modern_fish_min_version, '<')
|
|
) }}
|
|
|
|
- name: Add Fish shell PPA
|
|
become: true
|
|
ansible.builtin.apt_repository:
|
|
repo: "ppa:fish-shell/release-4"
|
|
state: present
|
|
update_cache: true
|
|
when: cli_modern_need_fish_ppa | bool
|
|
|
|
# --- Install packages ---
|
|
|
|
- name: Install CLI tools (apt)
|
|
become: true
|
|
ansible.builtin.apt:
|
|
name: "{{ cli_modern_deb_packages }}"
|
|
state: present
|
|
update_cache: true
|
|
vars:
|
|
cli_modern_deb_packages: >-
|
|
{{
|
|
(['fish'] if cli_modern_install_fish else []) +
|
|
(['fzf'] if cli_modern_install_fzf else []) +
|
|
(['zoxide'] if cli_modern_install_zoxide else []) +
|
|
(['bat'] if cli_modern_install_bat else []) +
|
|
(['eza'] if cli_modern_install_eza else []) +
|
|
(['fd-find'] if cli_modern_install_fd else []) +
|
|
(['ripgrep'] if cli_modern_install_ripgrep else []) +
|
|
(['fastfetch'] if cli_modern_install_fastfetch else [])
|
|
}}
|
|
when: cli_modern_deb_packages | length > 0
|
|
|
|
# On Debian/Ubuntu, fd is packaged as fd-find with binary named fdfind.
|
|
# Create a symlink so "fd" works everywhere.
|
|
- name: Symlink fdfind to fd
|
|
become: true
|
|
ansible.builtin.file:
|
|
src: /usr/bin/fdfind
|
|
dest: /usr/local/bin/fd
|
|
state: link
|
|
when: cli_modern_install_fd
|
|
failed_when: false
|
|
|
|
# On older Ubuntu, bat is packaged as batcat.
|
|
- name: Symlink batcat to bat
|
|
become: true
|
|
ansible.builtin.file:
|
|
src: /usr/bin/batcat
|
|
dest: /usr/local/bin/bat
|
|
state: link
|
|
when: cli_modern_install_bat
|
|
failed_when: false
|