dotfiles/.local/share/dotfiles/install_dev_tools.yml

139 lines
3.7 KiB
YAML

---
- hosts: all
vars:
common_packages:
- neovim
- ripgrep
- tree
- gcc
- fish
- zoxide
- git
- tldr
- fzf
brew_packages:
- difftastic
- fd
- uv
pacman_packages:
- difftastic
- fd
- uv
apt_packages:
- fd-find
uv_tools_default_python: '3.12'
uv_packages:
# python 3.12 is used by default
# if package requires another version, specify item
# - name: numpy
# python: 3.8
- name: aider-chat
- name: asciinema
- name: poetry
- name: basedpyright
- name: pre-commit
- name: posting
- name: ipython
macos_fish_path: /usr/local/bin/fish
arch_fish_path: /usr/bin/fish
tasks:
- name: Check the current OS family
ansible.builtin.set_fact:
is_macos: "{{ ansible_facts['os_family'] == 'Darwin' }}"
is_arch: "{{ ansible_facts['os_family'] == 'Archlinux' }}"
is_ubuntu: "{{ ansible_facts['os_family'] == 'Debian' }}"
- name: Get full packages list (macOS)
ansible.builtin.set_fact:
packages: "{{ common_packages + brew_packages }}"
when: is_macos
- name: Get full packages list (Manjaro)
ansible.builtin.set_fact:
packages: "{{ common_packages + pacman_packages }}"
when: is_arch
- name: Install packages (macOS)
community.general.homebrew:
name: "{{ packages }}"
state: present
when: is_macos
- name: Install packages (Manjaro)
community.general.pacman:
name: "{{ packages }}"
state: present
become: true
when: is_arch
- name: Install packages (Ubuntu)
when: is_ubuntu
become: true
ansible.builtin.apt:
pkg: "{{ common_packages }}"
cache_valid_time: 3600
- name: Install uv (Ubuntu)
when: is_ubuntu
block:
- name: Create a temporary directory
ansible.builtin.tempfile:
state: directory
prefix: uv_temp_
register: temp_dir
- name: Download uv tarball
ansible.builtin.get_url:
url: "https://github.com/astral-sh/uv/releases/download/0.5.16/uv-x86_64-unknown-linux-gnu.tar.gz"
dest: "{{ temp_dir.path }}/uv.tar.gz"
- name: Unpack the tarball
ansible.builtin.unarchive:
src: "{{ temp_dir.path }}/uv.tar.gz"
dest: "{{ temp_dir.path }}"
remote_src: yes
- name: Ensure ~/.local/bin exists
ansible.builtin.file:
path: "{{ ansible_env.HOME }}/.local/bin"
state: directory
mode: '0755'
- name: Move unpacked files to ~/.local/bin
ansible.builtin.copy:
src: "{{ temp_dir.path }}/uv-x86_64-unknown-linux-gnu/"
dest: "{{ ansible_env.HOME }}/.local/bin/"
remote_src: yes
mode: '0755'
- name: Clean up temporary directory
ansible.builtin.file:
path: "{{ temp_dir.path }}"
state: absent
- name: Install uv packages
ansible.builtin.command: "uv tool install --python {{ item.python | default(uv_tools_default_python) }} {{ item.name }}"
register: uv_install_result
changed_when: "'is already installed' not in uv_install_result.stderr"
loop: "{{ uv_packages }}"
tags:
- dev_tools
- name: Set fish as default shell
become: true
ansible.builtin.user:
name: "{{ ansible_env.USER }}"
shell: "{{ shell_path }}"
vars:
shell_path: "\
{% if is_macos %}{{ macos_fish_path }}\
{% elif is_arch %}{{ arch_fish_path }}\
{% else %}/bin/fish\
{% endif %}"