reorganizing configuration

- static package configuration in `vars/pkgs`
  - loaded into the variable `pkgconfig` as part of `tasks/main.yml`
This commit is contained in:
Matthew Stobbs
2025-02-12 12:52:55 -07:00
parent 9250145116
commit a3df5215b8
23 changed files with 259 additions and 226 deletions

View File

@@ -1,2 +1,7 @@
# vim: set filetype=yaml.ansible :
--- ---
# handlers file for ansible_role_package - name: Depend go
ansible.builtin.include_tasks:
file: addpkg.yml
vars:
pkg: go

7
tasks/config/air.yml Normal file
View File

@@ -0,0 +1,7 @@
# vim: set filetype=yaml.ansible :
---
- name: Set configuration for air
ansible.builtin.set_fact:
air:
ver: "{{ pkgconfig.air.version }}"
pkg: "{{ pkgconfig.air.git_repo }}@{{ pkgconfig.air.version }}"

View File

@@ -1,4 +1,22 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
version: 1.23.6 - name: Set go configuration
install_path: "{{ default_install_prefix }}" ansible.builtin.set_fact:
do_install_go: false # defaults to false to save on having to set facts needlessly
go:
ver: "{{ pkgconfig.go.version }}"
arch: "{{ pkgconfig_go.archmap[ansible_architecture] }}"
sys: "{{ ansible_system | lower }}"
ext: "{{ pkgconfig.go.extmap[ansible_system] }}"
- name: Set go composite facts
ansible.builtin.set_fact:
go:
ver: "{{ go.ver }}"
arch: "{{ go.arch }}"
sys: "{{ go.sys }}"
ext: "{{ go.ext }}"
archive: "go{{ go.ver }}.{{ go.sys }}-{{ go.arch }}.{{ pkgconfig_go.extmap[ansible_system] }}"
sum: "{{ pkgconfig.go.sums[go.ver][ansible_system][go.arch] }}"
url: "{{ pkgconfig.go.base_url }}/{{ go.archive }}"
inst_path: "{{ paths.install }}/go"

View File

@@ -2,8 +2,24 @@
--- ---
# create all the facts used throughout the role, but shouldn't be touched # create all the facts used throughout the role, but shouldn't be touched
# by the user # by the user
- name: Set facts based on use_local == true
when:
- use_local
ansible.builtin.set_fact:
paths: "{{ local_paths }}"
flatpak_method: user
- name: Set facts based on use_local == false
when:
- not use_local
ansible.builtin.set_fact:
paths: "{{ sys_paths }}"
flatpak_method: system
- name: Set installation facts - name: Set installation facts
ansible.builtin.set_fact: ansible.builtin.set_fact:
bin_dir: "{{ paths.install }}/bin"
state_dir: "{{ paths.install }}/state"
app_images: [] # app_images to install app_images: [] # app_images to install
cargo_pkgs: [] # rust packages from cargo cargo_pkgs: [] # rust packages from cargo
cask_pkgs: [] # homebrew casks cask_pkgs: [] # homebrew casks
@@ -19,39 +35,42 @@
- name: flathub - name: flathub
url: https://dl.flathub.org/repo/flathub.flatpakrepo url: https://dl.flathub.org/repo/flathub.flatpakrepo
- name: Set facts based on use_local == true
when:
- use_local
ansible.builtin.set_fact:
paths: "{{ local_paths }}"
flatpak_method: user
- name: Set facts based on use_local == false
when:
- not use_local
ansible.builtin.set_fact:
paths: "{{ sys_paths }}"
flatpak_method: system
- name: Set macOS specific facts - name: Set macOS specific facts
when: when:
- ansible_distribution == 'MacOSX' - ansible_system == 'Darwin'
ansible.builtin.set_fact:
pipx_exec: /opt/homebrew/bin/pipx
- name: Determine OS and set facts for it
block: block:
- name: Set macOS facts - name: Set pipx executable
when: ansible_os_family == 'Darwin' ansible.builtin.set_fact:
pipx_exec: /opt/homebrew/bin/pipx
- name: Set sys_pkg_become to false for homebrew
ansible.builtin.set_fact: ansible.builtin.set_fact:
sys_pkg_become: false sys_pkg_become: false
- name: Set Linux specific facts
when:
- ansible_system == 'Linux'
block:
- name: Set Linux facts - name: Set Linux facts
when: ansible_system == 'Linux'
ansible.builtin.set_fact: ansible.builtin.set_fact:
sys_pkg_become: true sys_pkg_become: true
- name: Ensure required paths exist
become: "{{ not use_local }}"
loop: "{{ paths + [bin_dir, state_dir] }}"
loop_control:
loop_var: path
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ path }}"
- name: Read default package configuration
ansible.builtin.include_vars:
dir: pkgs
extensions:
- yml
name: pkgconfig
- name: Generate package installation lists - name: Generate package installation lists
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: addpkg.yml file: addpkg.yml
@@ -155,10 +174,10 @@
name: "{{ flatpak.name }}" name: "{{ flatpak.name }}"
remote: "{{ flatpak.remote | default('flathub') }}" remote: "{{ flatpak.remote | default('flathub') }}"
- name: Ensure /usr/local/bin exists - name: Ensure prefix/bin exists
ansible.builtin.file: ansible.builtin.file:
state: directory state: directory
path: /usr/local/bin path: "{{ paths.install }}/bin"
owner: root owner: root
mode: '0755' mode: '0755'
become: true become: true

View File

@@ -1,9 +1,7 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
- ansible.builtin.include_tasks: - name: Add to go_pkgs
file: pkgs/go.yml notify:
when: pkgconfig_go is undefined - Depend go
- name: add to gopkgs
ansible.builtin.set_fact: ansible.builtin.set_fact:
gopkgs: "{{ gopkgs + ['github.com/air-verse/air@latest'] }}" go_pkgs: "{{ go_pkgs + [air.pkg] }}"

View File

@@ -1,11 +1,5 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
- ansible.builtin.include_vars: - name: Append to pkgs
file: go.yml
name: _go
- ansible.builtin.set_fact:
pkgconfig_go: "{{ _go | ansible.builtin.combine(pkgconfig.go) }}"
- name: append to pkgs
ansible.builtin.set_fact: ansible.builtin.set_fact:
srcpkgs: "{{ srcpkgs + [ 'go' ] }}" src_pkgs: "{{ src_pkgs + ['go'] }}"

View File

@@ -1,52 +1,40 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
- name: check go version - name: Check if archive already exists
ansible.builtin.command: ansible.builtin.stat:
cmd: "go version" path: "{{ paths.archive }}/{{ go_archive }}"
register: r_go_version register: stat_go_archive
ignore_errors: true
- name: install/update go - name: Install/update go
when:
- not stat_go_archive.exists
block: block:
- name: set go arch - name: Download go archive
ansible.builtin.set_fact: become: "{{ sys_pkg_become }}"
arch: "{{ pkgconfig_go.archmap[ansible_architecture] }}"
- name: set go archive filename
ansible.builtin.set_fact:
go_archive: "go{{ pkgconfig_go.version }}.{{ ansible_system | lower }}-{{ arch }}.{{ pkgconfig_go.extmap[ansible_system] }}"
- name: create temp path
ansible.builtin.tempfile:
state: directory
prefix: go_dl.
register: d_go_dl_tmp
- name: download go archive
become: true
ansible.builtin.get_url: ansible.builtin.get_url:
dest: "{{ d_go_dl_tmp.path }}/{{ go_archive }}" dest: "{{ paths.cache }}/{{ go_archive }}"
url: "https://go.dev/dl/{{ go_archive }}" url: "{{ go.url }}"
checksum: "{{ pkgconfig_go.sums[pkgconfig_go.version][ansible_system][arch] }}" checksum: "{{ go.sum }}"
decompress: false decompress: false
mode: '0644'
- name: ensure go install dir exists - name: Ensure go install dir exists
become: true become: "{{ sys_pkg_become }}"
ansible.builtin.file: ansible.builtin.file:
path: "{{ pkgconfig_go.install_path }}" path: "{{ go.inst_path }}"
state: directory state: directory
mode: '0755'
- name: extract go package - name: Extract go package
become: "{{ sys_pkg_become }}"
ansible.builtin.unarchive: ansible.builtin.unarchive:
dest: "{{ pkgconfig_go.install_path }}" dest: "{{ paths.archive }}/go"
src: "{{ d_go_dl_tmp.path }}/{{ go_archive }}" src: "{{ d_go_dl_tmp.path }}/{{ go_archive }}"
remote_src: true remote_src: true
when: ansible_system == 'Linux' when: ansible_system == 'Linux'
become: true
- name: install go macOS use pkg file - name: Install go macOS use pkg file
ansible.builtin.command: ansible.builtin.command:
cmd: "installer -pkg {{ d_go_dl_tmp.path }}/{{ go_archive }} -target /" cmd: "installer -pkg {{ d_go_dl_tmp.path }}/{{ go_archive }} -target /"
when: ansible_system == 'Darwin' when: ansible_system == 'Darwin'
become: true become: true
when: pkgconfig_go.version not in r_go_version.stdout

View File

@@ -5,12 +5,14 @@ use_local: true
prefer_method: system prefer_method: system
packages: [] # list of packages to install packages: [] # list of packages to install
local_paths: # all localpaths are prefixed with the users $HOME directory user_home: "{{ lookup(ansible.builtin.env, 'HOME') }}"
appimage: .local/appimage # keep appimages here
archive: .local/archive # extract archives here local_paths: # all localpaths are prefixed with the users "{{ user_home }} directory
cache: .cache # cache downloads here appimage: "{{ user_home }}/.local/appimage" # keep appimages here
cargo: .cargo # cargo install location archive: "{{ user_home }}/.local/archive" # extract archives here
install: .local # installation prefix. Binaries are placed in `{{ install }}/bin` cache: "{{ user_home }}/.cache" # cache downloads here
cargo: "{{ user_home }}/.cargo" # cargo install location
install: "{{ user_home }}/.local" # installation prefix. Binaries are placed in `{{ install }}/bin`
sys_paths: # if installing at a system level (default) sys_paths: # if installing at a system level (default)
appimage: /opt/appimage # appimages are installed to {{ apimage_install_prefix }}/<name>/ appimage: /opt/appimage # appimages are installed to {{ apimage_install_prefix }}/<name>/
@@ -19,152 +21,7 @@ sys_paths: # if installing at a system level (default)
cargo: /opt/cargo # cargo install location cargo: /opt/cargo # cargo install location
install: /usr/local # executables get linked to {{ default_install_prefix }}/bin install: /usr/local # executables get linked to {{ default_install_prefix }}/bin
pkgconfig: pkgconfig:
alacritty:
version: 0.15.0
RedHat:
pkgs: []
build_deps:
- cmake
- freetype-devel
- fontconfig-devel
- libxcb-devel
- libxkbcommon-devel
- g++
Debian:
pkgs: []
build_deps:
- cmake
- pkg-config
- libfreetype6-dev
- libfontconfig1-dev
- libxcb-xfixes0-dev
- libxkbcommon-dev
- python3
Darwin:
pkgs:
- alacritty
git_repo: https://github.com/alacritty/alacritty.git
bitwarden:
flatpak:
name: com.bitwarden.desktop
remote: flathub
appimage:
name: bitwarden.appimage
url: https://vault.bitwarden.com/download/?app=desktop&platform=linux&variant=appimage
broot:
build_deps:
Debian:
- build-essential
- libxcb1-dev
- libxcb-render0-dev
- libxcb-shape0-dev
- libxcb-xfixes0-dev
RedHat:
- libxcb
carapace:
pkgs:
Linux:
- carapace-bin
Darwin:
- carapace
clangd:
pkgs:
RedHat:
- clang-devel
Debian:
- clangd-12
Darwin:
- llvm
consul:
Linux: consul
Darwin: hashicorp/tap/consul
fd:
pkg:
Darwin:
- fd
RedHat:
- fd-find
Debian:
- fd-find
flatpak: {}
ghostty:
build_deps:
Debian:
- libgtk-4-dev
- libadwaita-1-dev
RedHat:
- gtk4-devel
- libadwaita-devel
git_repo: https://github.com/ghostty-org/ghostty
git:
pkgs:
Darwin:
- git
- git-delta
- git-extras
- git-lfs
Linux:
- git
- git-delta
- git-email
- git-lfs
go:
archmap:
arm64: arm64
aarch64: arm64
x86_64: amd64
extmap:
Darwin: pkg
Linux: tar.gz
sums:
1.23.6:
Darwin:
amd64: sha256:7fa387c228b4dd69b518a5d9425638fa5c0d86ec8943de373e3802aff2e5b12a
arm64: sha256:a167758a44e08af6eddf844ed86a6acdbff1d3957248913bbca7ee4ef6ff07d0
Linux:
amd64: sha256:9379441ea310de000f33a4dc767bd966e72ab2826270e038e78b2c53c2e7802d
arm64: sha256:561c780e8f4a8955d32bf72e46af0b5ee5e0debe1e4633df9a03781878219202
1.23.5:
Darwin:
amd64: sha256:d2b06bf0b8299e0187dfe2d8ad39bd3dd96a6d93fe4d1cfd42c7872452f4a0a2
arm64: sha256:f819ed94939e08a5016b9a607ec84ebbde6cb3fe59750c59d97aa300c3fd02df
Linux:
amd64: sha256:cbcad4a6482107c7c7926df1608106c189417163428200ce357695cc7e01d091
arm64: sha256:47c84d332123883653b70da2db7dd57d2a865921ba4724efcdf56b5da7021db0
hashicorp:
Linux:
RedHat:
repo: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Fedora:
repo: https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
Debian:
repo: "deb [arch={{ ansible_architecture }} signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main"
jellyfin: {}
kitty:
pkgs:
Darwin:
- kitty
Linux:
- kitty
- kitty-shell-integration
libreoffice:
flatpak:
- org.libreoffice.LibreOffice
Debian:
- libreoffice
RedHat:
- libreoffice
luals:
base_url: https://github.com/LuaLS/lua-language-server/releases/download
sysmap:
Darwin: darwin
Linux: linux
archmap:
aarch64: arm64
arm64: arm64
x86_64: x64
neovide: neovide:
git_repo: https://github.com/neovide/neovide.git git_repo: https://github.com/neovide/neovide.git
build_deps: build_deps:

3
vars/pkgs/air.yml Normal file
View File

@@ -0,0 +1,3 @@
air:
version: latest
git_repo: github.com/air-verse/air

25
vars/pkgs/alacritty.yml Normal file
View File

@@ -0,0 +1,25 @@
alacritty:
version: 0.15.0
RedHat:
pkgs: []
build_deps:
- cmake
- freetype-devel
- fontconfig-devel
- libxcb-devel
- libxkbcommon-devel
- g++
Debian:
pkgs: []
build_deps:
- cmake
- pkg-config
- libfreetype6-dev
- libfontconfig1-dev
- libxcb-xfixes0-dev
- libxkbcommon-dev
- python3
Darwin:
pkgs:
- alacritty
git_repo: https://github.com/alacritty/alacritty.git

7
vars/pkgs/bitwarden.yml Normal file
View File

@@ -0,0 +1,7 @@
bitwarden:
flatpak:
name: com.bitwarden.desktop
remote: flathub
appimage:
name: bitwarden.appimage
url: https://vault.bitwarden.com/download/?app=desktop&platform=linux&variant=appimage

10
vars/pkgs/broot.yml Normal file
View File

@@ -0,0 +1,10 @@
broot:
build_deps:
Debian:
- build-essential
- libxcb1-dev
- libxcb-render0-dev
- libxcb-shape0-dev
- libxcb-xfixes0-dev
RedHat:
- libxcb

6
vars/pkgs/carapace.yml Normal file
View File

@@ -0,0 +1,6 @@
carapace:
pkgs:
Linux:
- carapace-bin
Darwin:
- carapace

8
vars/pkgs/clangd.yml Normal file
View File

@@ -0,0 +1,8 @@
clangd:
pkgs:
RedHat:
- clang-devel
Debian:
- clangd-12
Darwin:
- llvm

3
vars/pkgs/consul.yml Normal file
View File

@@ -0,0 +1,3 @@
consul:
Linux: consul
Darwin: hashicorp/tap/consul

8
vars/pkgs/fd.yml Normal file
View File

@@ -0,0 +1,8 @@
fd:
pkg:
Darwin:
- fd
RedHat:
- fd-find
Debian:
- fd-find

9
vars/pkgs/ghostty.yml Normal file
View File

@@ -0,0 +1,9 @@
ghostty:
build_deps:
Debian:
- libgtk-4-dev
- libadwaita-1-dev
RedHat:
- gtk4-devel
- libadwaita-devel
git_repo: https://github.com/ghostty-org/ghostty

12
vars/pkgs/git.yml Normal file
View File

@@ -0,0 +1,12 @@
git:
pkgs:
Darwin:
- git
- git-delta
- git-extras
- git-lfs
Linux:
- git
- git-delta
- git-email
- git-lfs

25
vars/pkgs/go.yml Normal file
View File

@@ -0,0 +1,25 @@
go:
base_url: https://go.dev/dl
version: 1.23.6
archmap:
arm64: arm64
aarch64: arm64
x86_64: amd64
extmap:
Darwin: pkg
Linux: tar.gz
sums:
1.23.6:
Darwin:
amd64: sha256:7fa387c228b4dd69b518a5d9425638fa5c0d86ec8943de373e3802aff2e5b12a
arm64: sha256:a167758a44e08af6eddf844ed86a6acdbff1d3957248913bbca7ee4ef6ff07d0
Linux:
amd64: sha256:9379441ea310de000f33a4dc767bd966e72ab2826270e038e78b2c53c2e7802d
arm64: sha256:561c780e8f4a8955d32bf72e46af0b5ee5e0debe1e4633df9a03781878219202
1.23.5:
Darwin:
amd64: sha256:d2b06bf0b8299e0187dfe2d8ad39bd3dd96a6d93fe4d1cfd42c7872452f4a0a2
arm64: sha256:f819ed94939e08a5016b9a607ec84ebbde6cb3fe59750c59d97aa300c3fd02df
Linux:
amd64: sha256:cbcad4a6482107c7c7926df1608106c189417163428200ce357695cc7e01d091
arm64: sha256:47c84d332123883653b70da2db7dd57d2a865921ba4724efcdf56b5da7021db0

8
vars/pkgs/hashicorp.yml Normal file
View File

@@ -0,0 +1,8 @@
hashicorp:
Linux:
RedHat:
repo: https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
Fedora:
repo: https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
Debian:
repo: "deb [arch={{ ansible_architecture }} signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com {{ ansible_distribution_release }} main"

7
vars/pkgs/kitty.yml Normal file
View File

@@ -0,0 +1,7 @@
kitty:
pkgs:
Darwin:
- kitty
Linux:
- kitty
- kitty-shell-integration

View File

@@ -0,0 +1,7 @@
libreoffice:
flatpak:
- org.libreoffice.LibreOffice
Debian:
- libreoffice
RedHat:
- libreoffice

9
vars/pkgs/luals.yml Normal file
View File

@@ -0,0 +1,9 @@
luals:
base_url: https://github.com/LuaLS/lua-language-server/releases/download
sysmap:
Darwin: darwin
Linux: linux
archmap:
aarch64: arm64
arm64: arm64
x86_64: x64