251 lines
6.7 KiB
YAML
251 lines
6.7 KiB
YAML
# vim: set filetype=yaml.ansible :
|
|
---
|
|
- name: Set facts based on use_local == true
|
|
when:
|
|
- use_local
|
|
ansible.builtin.set_fact:
|
|
archive_become: false
|
|
path_prefix: "{{ lookup(ansible.builtin.env, 'HOME') }}/.local"
|
|
flatpak_method: user
|
|
|
|
- name: Set facts based on use_local == false
|
|
when:
|
|
- not use_local
|
|
ansible.builtin.set_fact:
|
|
archive_become: true
|
|
path_prefix: "{{ defaults.path.prefix }}"
|
|
flatpak_method: system
|
|
|
|
- name: Set macOS specific facts
|
|
when:
|
|
- ansible_system == 'Darwin'
|
|
block:
|
|
- name: Set homebrew bin path
|
|
ansible.builtin.set_fact:
|
|
homebrew_bin: "/opt/homebrew/bin"
|
|
- name: Set other macOS facts
|
|
ansible.builtin.set_fact:
|
|
dobecome: "{{ not use_local }}"
|
|
pipx_exec: "{{ homebrew_bin }}/pipx"
|
|
sys_pkg_become: false
|
|
|
|
- name: Set Linux specific facts
|
|
when:
|
|
- ansible_system == 'Linux'
|
|
block:
|
|
- name: Set Linux facts
|
|
ansible.builtin.set_fact:
|
|
dobecome: "{{ not use_local }}"
|
|
sys_pkg_become: true
|
|
|
|
- name: Set paths
|
|
ansible.builtin.set_fact:
|
|
paths:
|
|
appimage: "{{ appimage_path | default(path_prefix ~ defaults.path.suffix.appimage) }}"
|
|
archive: "{{ archive_path | default(path_prefix ~ defaults.path.suffix.archive) }}"
|
|
bin: "{{ bin_path | default(path_prefix ~ defaults.path.suffix.bin) }}"
|
|
cargo: "{{ cargo_path | default(path_prefix ~ defaults.path.suffix.cargo) }}"
|
|
go: "{{ goroot | default(path_prefix ~ defaults.path.suffix.go) }}"
|
|
pipx: "{{ pipx_path | default(path_prefix ~ defaults.path.suffix.pipx) }}"
|
|
|
|
- name: Set installation facts
|
|
ansible.builtin.set_fact:
|
|
# repositories
|
|
brew_taps: [] # homebrew taps
|
|
flatpak_remotes: # flatpak remotes, includes flathub by default
|
|
- name: flathub
|
|
url: https://dl.flathub.org/repo/flathub.flatpakrepo
|
|
# install lists
|
|
app_images: [] # app_images to install
|
|
archive_pkgs: [] # packages installed via prebuilt archive
|
|
cargo_pkgs: [] # rust packages from cargo
|
|
cask_pkgs: [] # homebrew casks
|
|
flatpaks: [] # flatpaks
|
|
go_pkgs: [] # go applications
|
|
npm_pkgs: [] # npm commands
|
|
pipx_pkgs: [] # pipx packages
|
|
src_pkgs: [] # packages built from source
|
|
sys_pkgs: [] # system package manager packages
|
|
tap_pkgs: [] # homebrew tap packages
|
|
|
|
- name: Ensure required paths exist
|
|
become: "{{ dobecome }}"
|
|
loop: "{{ paths | dict2items }}"
|
|
loop_control:
|
|
loop_var: path
|
|
ansible.builtin.file:
|
|
state: directory
|
|
mode: '0755'
|
|
path: "{{ path.value }}"
|
|
|
|
- name: Read default package configuration
|
|
ansible.builtin.include_vars:
|
|
dir: pkgs
|
|
extensions:
|
|
- yml
|
|
name: pkgconfig
|
|
|
|
- name: Generate package installation lists
|
|
ansible.builtin.include_tasks:
|
|
file: addpkg.yml
|
|
loop: "{{ packages | unique }}"
|
|
loop_control:
|
|
loop_var: pkg
|
|
|
|
- name: Install sys_pkgs list
|
|
become: "{{ sys_pkg_become }}"
|
|
ansible.builtin.package:
|
|
name: "{{ sys_pkgs | unique }}"
|
|
state: present
|
|
|
|
- name: Redhat based OS
|
|
when: ansible_os_family == 'RedHat'
|
|
block:
|
|
- name: Install dnf packages
|
|
become: true
|
|
when:
|
|
- sys_pkgs|length > 0
|
|
ansible.builtin.dnf:
|
|
name: "{{ sys_pkgs | unique }}"
|
|
state: present
|
|
|
|
- name: Debian based OS
|
|
when: ansible_os_family == 'Debian'
|
|
block:
|
|
- name: Install apt packages
|
|
ansible.builtin.apt:
|
|
name: "{{ sys_pkgs | unique }}"
|
|
state: "{{ install_state }}"
|
|
become: true
|
|
when:
|
|
- sys_pkgs|length > 0
|
|
|
|
- name: Darwin/macOS based OS
|
|
when: ansible_os_family == 'Darwin'
|
|
block:
|
|
- name: Upgrade homebrew packages
|
|
community.general.homebrew:
|
|
name: "*"
|
|
state: latest
|
|
when: full_upgrade
|
|
|
|
- name: Tap homebrew taps
|
|
community.general.homebrew_tap:
|
|
name: "{{ brew_taps | unique }}"
|
|
state: present
|
|
when: brew_taps|length > 0
|
|
|
|
- name: Install homebrew packages
|
|
community.general.homebrew:
|
|
name: "{{ sys_pkgs | unique }}"
|
|
state: "{{ install_state }}"
|
|
when: sys_pkgs|length > 0
|
|
|
|
- name: Install homebrew casks
|
|
community.general.homebrew_cask:
|
|
name: "{{ cask_pkgs | unique }}"
|
|
state: "{{ install_state }}"
|
|
when: cask_pkgs|length > 0
|
|
|
|
- name: Workaround to install homebrew taps
|
|
ansible.builtin.command:
|
|
cmd: "brew install {{ tap_pkg }}"
|
|
loop: "{{ tap_pkgs | unique }}"
|
|
loop_control:
|
|
loop_var: tap_pkg
|
|
# TODO: fix the need to have this workaround
|
|
|
|
- name: Install flatpaks on Linux Systems
|
|
when:
|
|
- ansible_system == 'Linux'
|
|
block:
|
|
- name: Add flatpak repos
|
|
when:
|
|
- flatpak_remotes|length > 0
|
|
become: "{{ not use_local }}"
|
|
loop: "{{ flatpak_remotes | unique }}"
|
|
loop_control:
|
|
loop_var: remote
|
|
community.general.flatpak_remote:
|
|
enabled: true
|
|
method: "{{ flatpak_method }}"
|
|
state: present
|
|
flatpakrepo_url: "{{ remote.url }}"
|
|
name: "{{ remote.name }}"
|
|
|
|
- name: Install flatpaks
|
|
become: true
|
|
loop: "{{ flatpaks | unique }}"
|
|
loop_control:
|
|
loop_var: flatpak
|
|
community.general.flatpak:
|
|
state: latest
|
|
method: "{{ flatpak_method }}"
|
|
name: "{{ flatpak.name }}"
|
|
remote: "{{ flatpak.remote | default('flathub') }}"
|
|
|
|
- name: Install archive_pkgs
|
|
when:
|
|
- archive_pkgs|length > 0
|
|
loop: "{{ archive_pkgs }}"
|
|
loop_control:
|
|
loop_var: pkg
|
|
ansible.builtin.include_tasks:
|
|
file: "archive/{{ pkg }}.yml"
|
|
|
|
- name: Install src_pkgs
|
|
when:
|
|
- src_pkgs|length > 0
|
|
loop: "{{ src_pkgs | unique }}"
|
|
loop_control:
|
|
loop_var: pkg
|
|
ansible.builtin.include_tasks:
|
|
file: "src/{{ pkg }}.yml"
|
|
|
|
- name: Install cargo packages
|
|
when:
|
|
- cargo_pkgs|length > 0
|
|
become: "{{ not use_local }}"
|
|
loop: "{{ cargo_pkgs | unique }}"
|
|
loop_control:
|
|
loop_var: pkg
|
|
community.general.cargo:
|
|
name: "{{ pkg.cargo.pkg }}"
|
|
version: "{{ pkg.ver }}"
|
|
path: "{{ paths.cargo }}"
|
|
locked: "{{ pkg.cargo.locked }}"
|
|
|
|
- name: Install go packages
|
|
when:
|
|
- go_pkgs|length > 0
|
|
loop: "{{ go_pkgs | unique }}"
|
|
loop_control:
|
|
loop_var: pkg
|
|
environment:
|
|
GOBIN: "{{ paths.bin }}"
|
|
PATH: "{{ paths.go }}/bin:$PATH"
|
|
ansible.builtin.include_tasks:
|
|
file: go.yml
|
|
|
|
- name: Install local npm packages
|
|
when:
|
|
- npm_pkgs|length > 0
|
|
become: "{{ archive_become }}"
|
|
loop: "{{ npm_pkgs | unique }}"
|
|
loop_control:
|
|
loop_var: npm_pkg
|
|
community.general.npm:
|
|
global: true
|
|
name: "{{ npm_pkg }}"
|
|
state: latest
|
|
|
|
- name: Install python pipx packages for user
|
|
loop: "{{ pipx_pkgs | unique }}"
|
|
loop_control:
|
|
loop_var: pipx_pkg
|
|
when: pipx_pkgs|length > 0
|
|
community.general.pipx:
|
|
executable: "{{ pipx_exec }}"
|
|
name: "{{ pipx_pkg }}"
|
|
state: latest
|