change layout for better management

- instead of just `syspkgs` and `srcpkgs` add more lists
  - `appimages`, `flatpkgs` and others as they come up
This commit is contained in:
Matthew Stobbs
2025-02-11 17:51:10 -07:00
parent 9ec814257f
commit 275f5df722
19 changed files with 295 additions and 224 deletions

View File

@@ -1,23 +1,11 @@
# vim: set filetype=yaml.ansible :
---
- name: "check if task for {{pkg}} exists"
ansible.builtin.command: "test -f {{role_path}}/tasks/pkgs/{{ pkg }}.yml"
- name: "Check if task exists for {{ pkg }}"
ansible.builtin.stat:
path: "{{ role_path }}/tasks/pkgs/{{ pkg }}.yml"
register: cpkg_exists
ignore_errors: true
failed_when: not (cpkg_exists.rc != 0 or cpkg_exists.rc != 1)
- name: "add include task for {{pkg}}"
- name: "Add include task for {{ pkg }}"
when: cpkg_exists.exists
ansible.builtin.include_tasks:
file: "pkgs/{{ pkg }}.yml"
when: cpkg_exists.rc == 0
tags:
- packages
- name: "add {{pkg}} to syspkgs if task doesn't exist: {{assume_missing_is_syspkg}}"
ansible.builtin.set_fact:
syspkgs: "{{ syspkgs + [pkg] }}"
when:
- cpkg_exists.rc != 0
- assume_missing_is_syspkg
tags:
- packages

View File

@@ -0,0 +1,31 @@
# vim: set filetype=yaml.ansible :
---
- name: Install bitwarden appimage
become: "{{ bw_become }}"
become_user: "{% if bw_become %}{{ bw_owner }}{% else %}~{% endif %}"
when:
- bw_instmtd == 'appimage'
block:
- name: Ensure install path exists
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ bw_instdir }}"
owner: "{{ bw_owner }}"
group: "{{ bw_group }}"
- name: Fetch bitwarden appimage
ansible.builtin.get_url:
mode: '0755'
decompress: false
backup: true
url: bw_appimg.url
dest: "{{ bw_instdir }}/{{ bw_appimg.name }}"
owner: "{{ bw_owner }}"
group: "{{ bw_group }}"
- name: Link bitwarden appimage
ansible.builtin.file:
state: link
src: "{{ bw_instdir }}/{{ bw_appimg.name }}"
path: "{{ bw_instpfx }}/bin/bitwarden"

View File

@@ -1,7 +1,9 @@
# vim: set filetype=yaml.ansible :
---
- name: build and install alacritty
- name: Build and install alacritty
become: true
ansible.builtin.command:
creates: "{{ pkgconfig_alacritty.install_prefix }}/bin/alacritty"
cmd:
- cargo
- install
@@ -11,4 +13,3 @@
- "{{ pkgconfig_alacritty.git_repo }}"
- --tag
- "v{{ pkgconfig_alacritty.version }}"
become: true

View File

@@ -1,28 +0,0 @@
# vim: set filetype=yaml.ansible :
---
- name: Install bitwarden appimage
blocK:
- ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ pkgconfig_bitwarden.install_dir }}"
owner: "{{ pkgconfig_bitwarden.owner }}"
group: "{{ pkgconfig_bitwarden.group }}"
- ansible.builtin.get_url:
mode: '0755'
decompress: false
backup: true
url: "https://vault.bitwarden.com/download/?app=desktop&platform=linux&variant=appimage"
dset: "{{ pkgconfig_bitwarden.install_dir }}/bitwarden.appimage"
owner: "{{ pkgconfig_bitwarden.owner }}"
group: "{{ pkgconfig_bitwarden.group }}"
- ansible.builtin.file:
state: link
src: "{{ pkgconfig_bitwarden.install_dir }}/bitwarden.appimage"
path: "{{ pkgconfig_bitwarden.install_prefix }}/bin/bitwarden"
when:
- pkgconfig_bitwarden.use_appimage
beocome: "{{ pkgconfig_bitwarden.dobecome }}"
become_user: "{% if pkgconfig_bitwarden.dobecome %}{{ pkgconfig_bitwarden.owner }}{% else %}~{% endif %}"

View File

@@ -1,27 +1,27 @@
# vim: set filetype=yaml.ansible :
---
- name: build ghostty from source
- name: Build ghostty from source
block:
- name: create temp path
- name: Create temp path
ansible.builtin.tempfile:
state: directory
prefix: ghostty.
register: d_ghostty_tmp
- name: clone ghostty git repository
- name: Clone ghostty git repository
ansible.builtin.git:
depth: 1
dest: "{{ d_ghostty_tmp.path }}/ghostty"
repo: "{{ pkgconfig_ghostty.git_repo }}"
version: "{{ pkgconfig_ghostty.version }}"
- name: build ghostty
- name: Build ghostty
ansible.builtin.command:
chdir: "{{ d_ghostty_tmp.path }}/ghostty"
cmd: "zig build -D{{ pkgconfig_ghostty.optimize }}"
register: c_ghostty_build
- name: install ghostty
- name: Install ghostty
ansible.file.copy:
src: "{{ d_ghostty_tmp.path }}/ghostty/zig-out/bin/ghostty"
dest: "{{ pkgconfig_ghostty.install_prefix }}/bin/ghostty"

View File

@@ -2,11 +2,20 @@
---
- name: Set needed variables lua language server
ansible.builtin.set_fact:
luals_pkg: "lua-language-server-{{ pkgconfig_luals.version }}-{{ pkgconfig_luals.sysmap[ansible_system] }}-{{ pkgconfig_luals.archmap[ansible_architecture] }}.tar.gz"
luals_sys: pkgconfig_luals.sysmap[ansible_system]
luals_arch: pkgconfig_luals.archmap[ansible_architecture]
luals_ver: pkgconfig_luals.version
luals_instpath: pkgconfig_luals.install_path
luals_instpfx: pkgconfig_luals.install_prefix
luals_burl: pkgconfig_luals.base_url
- name: Set luals archive name
ansible.builtin.set_fact:
luals_pkg: "lua-language-server-{{ luals_ver }}-{{ lualsl_sys }}-{{ luals_arch }}.tar.gz"
- name: Check if lua language server is already installed
ansible.builtin.stat:
path: "{{ pkgconfig_luals.install_path }}/bin/lua-language-server"
path: "{{ luals_instpath }}/bin/lua-language-server"
register: r_luals_stat
- name: Install lua-language-server
@@ -21,20 +30,20 @@
- name: Get latest lua-language-server
ansible.builtin.get_url:
dest: "{{ d_luals_dl_tmp.path }}/{{ luals_pkg }}"
url: "{{ pkgconfig_luals.base_url }}/{{ pkgconfig_luals.version }}/{{ luals_pkg }}"
url: "{{ luals_burl }}/{{ luals_ver }}/{{ luals_pkg }}"
mode: "0644"
decompress: false
- name: Create install_path
ansible.builtin.file:
state: directory
path: "{{ pkgconfig_luals.install_path }}"
path: "{{ luals_instpath }}"
mode: "0755"
become: true
- name: Extract lua language server archive
ansible.builtin.unarchive:
dest: "{{ pkgconfig_luals.install_path }}"
dest: "{{ luals_instpath }}"
src: "{{ d_luals_dl_tmp.path }}/{{ luals_pkg }}"
remote_src: true
become: true
@@ -42,6 +51,6 @@
- name: Link lua language server binary
ansible.builtin.file:
state: link
src: "{{ pkgconfig_luals.install_path }}/bin/lua-language-server"
path: "{{ pkgconfig_luals.install_prefix }}/bin/lua-language-server"
src: "{{ luals_instpath }}/bin/lua-language-server"
path: "{{ luals_instpfx }}/bin/lua-language-server"
become: true

View File

@@ -1,64 +1,45 @@
# vim: set filetype=yaml.ansible :
---
- name: generate package installation lists
- name: Determine OS and set facts for it
block:
- name: Set macOS facts
when: ansible_os_family == 'Darwin'
ansible.builtin.set_fact:
syspkg_become: false
- name: Set Linux facts
when: ansible_system == 'Linux'
ansible.builtin.set_fact:
syspkg_become: true
- name: Generate package installation lists
ansible.builtin.include_tasks:
file: addpkg.yml
loop: "{{ packages | unique }}"
loop_control:
loop_var: pkg
- name: redhat based OS
block:
- name: upgrade dnf packages
ansible.builtin.dnf:
name: "*"
state: latest
become: true
when: full_upgrade
- name: Install syspkgs list
become: "{{ syspkg_become }}"
ansible.builtin.package:
name: "{{ syspkgs | unique }}"
state: present
- name: install dnf packages
ansible.builtin.dnf:
name: "{{ syspkgs | unique }}"
state: "{{ install_state }}"
become: true
when:
- syspkgs|length > 0
- name: add flatpak repos
community.general.flatpak_remote:
enabled: true
flatpakrepo_url: "{{ repo.url }}"
method: system
name: "{{ repo.name }}"
state: present
loop: "{{ flatpkg_repo }}"
loop_control:
loop_var: repo
become: true
when:
- flatpkg_repo|length > 0
- flatpkgs|length > 0
- name: install flatpaks
community.general.flatpak:
method: "system"
name: "{{ flatpkgs }}"
state: latest
become: true
when:
- flatpkgs|length > 0
- name: Redhat based OS
when: ansible_os_family == 'RedHat'
- name: debian based OS
block:
- name: upgrade apt packages
ansible.builtin.apt:
name: "*"
state: latest
- name: Install dnf packages
become: true
when: full_upgrade
when:
- syspkgs|length > 0
ansible.builtin.dnf:
name: "{{ syspkgs | unique }}"
state: present
- name: install apt packages
- name: Debian based OS
when: ansible_os_family == 'Debian'
block:
- name: Install apt packages
ansible.builtin.apt:
name: "{{ syspkgs | unique }}"
state: "{{ install_state }}"
@@ -66,66 +47,75 @@
when:
- syspkgs|length > 0
- name: add flatpak repos
community.general.flatpak_remote:
enabled: true
flatpakrepo_url: "{{ repo.url }}"
method: system
name: "{{ repo.name }}"
state: present
loop: "{{ flatpkg_repo | unique }}"
loop_control:
loop_var: repo
become: true
when:
- flatpkg_repo|length > 0
- flatpkgs|length > 0
- name: install flatpaks
community.general.flatpak:
method: "system"
name: "{{ flatpkgs | unique }}"
state: latest
become: true
when:
- flatpkgs|length > 0
when: ansible_os_family == 'Debian'
- name: darwin/macOS based OS
- name: Darwin/macOS based OS
when: ansible_os_family == 'Darwin'
block:
- name: upgrade homebrew packages
- name: Upgrade homebrew packages
community.general.homebrew:
name: "*"
state: latest
when: full_upgrade
- name: tap homebrew taps
- name: Tap homebrew taps
community.general.homebrew_tap:
name: "{{ brewtaps | unique }}"
state: present
when: brewtaps|length > 0
- name: install homebrew packages
- name: Install homebrew packages
community.general.homebrew:
name: "{{ syspkgs | unique }}"
state: "{{ install_state }}"
when: syspkgs|length > 0
- name: install homebrew casks
- name: Install homebrew casks
community.general.homebrew_cask:
name: "{{ caskpkgs | unique }}"
state: "{{ install_state }}"
when: caskpkgs|length > 0
- name: workaround to install homebrew taps
- name: Workaround to install homebrew taps
ansible.builtin.command:
cmd: "brew install {{ tappkg }}"
loop: "{{ tappkgs | unique }}"
loop_control:
loop_var: tappkg
when: ansible_os_family == 'Darwin'
# TODO: fix the need to have this workaround
- name: ensure /usr/local/bin exists
- name: Install flatpaks on Linux Systems
when:
- ansible_system == 'Linux'
- flatpkgs|length > 0
block:
- name: Add flatpak repos
become: true
loop: "{{ fpremotes | unique }}"
loop_control:
loop_var: remote
when:
- fpremotes|length > 0
- flatpkgs|length > 0
community.general.flatpak_remote:
enabled: true
method: system
state: present
flatpakrepo_url: "{{ remote.url }}"
name: "{{ remote.name }}"
- name: Install flatpaks
become: true
loop: "{{ flatpkgs | unique }}"
loop_control:
loop_var: flatpkg
when:
- flatpkgs|length > 0
community.general.flatpak:
state: latest
method: system
name: "{{ flatpkg.name }}"
remote: "{{ flatpkg.remote | default('flathub') }}"
- name: Ensure /usr/local/bin exists
ansible.builtin.file:
state: directory
path: /usr/local/bin
@@ -133,7 +123,7 @@
mode: '0755'
become: true
- name: install srcpkgs
- name: Install srcpkgs
ansible.builtin.include_tasks:
file: "build/{{ srcpkg }}.yml"
loop: "{{ srcpkgs | unique }}"
@@ -141,11 +131,11 @@
loop_var: srcpkg
when: srcpkgs|length > 0
- name: install cargo packages at specific version
- name: Install cargo packages at specific version
community.general.cargo:
name: "{{ cargopkg.name }}"
version: "{{ cargopkg.version }}"
path: "{{ cargopkg.path | default(default_config.install_prefix) }}"
path: "{{ cargopkg.path | default(default_install_prefix) }}"
locked: "{{ cargopkg.locked | default(false) }}"
become: true
when: cargoversioned|length > 0
@@ -164,32 +154,33 @@
loop_var: cargopkg
- name: Install local go packages
loop: "{{ gopkgs | unique }}"
loop_control:
loop_var: gopkg
when: gopkgs|length > 0
environment:
GOROOT: /usr/local/go
PATH: /usr/local/go/bin:$PATH
ansible.builtin.command:
cmd: "go install {{ gopkg }}"
loop: "{{ gopkgs | unique }}"
loop_control:
loop_var: gopkg
when: gopkgs|length > 0
#TODO: figure out how to check if the gopkg is already installed
- name: Install local npm packages
community.general.npm:
global: true
name: "{{ npmpkg }}"
state: latest
loop: "{{ npmpkgs | unique }}"
loop_control:
loop_var: npmpkg
when: npmpkgs|length > 0
community.general.npm:
global: true
name: "{{ npmpkg }}"
state: latest
- name: Install python pipx packages for user
community.general.pipx:
executable: "{% if ansible_os_family == 'Darwin' %}/opt/homebrew/bin/pipx{% else %}/usr/bin/pipx{% endif %}"
name: "{{ pipxpkg }}"
state: latest
loop: "{{ pipxpkgs | unique }}"
loop_control:
loop_var: pipxpkg
when: pipxpkgs|length > 0
community.general.pipx:
executable: "{% if ansible_os_family == 'Darwin' %}/opt/homebrew/bin/pipx{% else %}/usr/bin/pipx{% endif %}"
name: "{{ pipxpkg }}"
state: latest

View File

@@ -1,31 +1,48 @@
# vim: set filetype=yaml.ansible :
---
- ansible.builtin.include_vars:
- name: Read bitwarden configuration
ansible.builtin.include_vars:
file: bitwarden.yml
name: _bitwarden
- ansible.builtin.set_fact:
- name: Set bitwarden configuration
ansible.builtin.set_fact:
pkgconfig_bitwarden: "{{ _bitwarden | ansible.builtin.combine(pkgconfig.bitwarden) }}"
- name: append to flatpkgs
- name: Set bitwarden facts
ansible.builtin.set_fact:
bw:
appimg: pkgconfig_bitwarden.appimage
become: pkgconfig_bitwarden.dobecome
flatpak: pkgconfig_bitwarden.flatpak
group: pkgconfig_bitwarden.group
instdir: pkgconfig_bitwarden.install_dir
instmtd: pkgconfig_bitwarden.install_method
instpfx: pkgconfig_bitwarden.install_prefix
owner: pkgconfig_bitwarden.owner
- name: Append to flatpkgs
when:
- ansible_os_family != 'Darwin'
- bw.instmtd == 'flatpak'
block:
- ansible.builtin.include_tasks:
- name: Ensure flatpak runtime activated
ansible.builtin.include_tasks:
file: pkgs/flatpak.yml
when: flatpak is undefined
- ansible.builtin.set_fact:
flatpkgs: "{{ flatpkgs + [ 'com.bitwarden.desktop' ] }}"
- name: Append to flatpkgs
ansible.builtin.set_fact:
flatpkgs: "{{ flatpkgs + [bw.flatpak] }}"
- name: Append to srcpkgs
when:
- ansible_os_family != 'Darwin'
- pkgconfig_bitwarden.use_flatpak
- name: append to srcpkgs
- bw.instmtd == 'appimage'
ansible.builtin.set_fact:
syspkgs: "{{ srcpkgs + [ 'bitwarden' ] }}"
when:
- ansible_os_family != 'Darwin'
- not pkgconfig_bitwarden.use_flatpak
syspkgs: "{{ appimages + ['bitwarden'] }}"
- name: append to caskpkgs
ansible.builtin.set_fact:
caskpkgs: "{{ caskpkgs + [ 'bitwarden' ] }}"
- name: Append to caskpkgs
when: ansible_os_family == 'Darwin'
ansible.builtin.set_fact:
caskpkgs: "{{ caskpkgs + ['bitwarden'] }}"

View File

@@ -1,11 +1,23 @@
# vim: set filetype=yaml.ansible :
---
- ansible.builtin.include_vars:
file: lua-language-server.yml
name: _luals
- ansible.builtin.set_fact:
pkgconfig_luals: "{{ _luals | ansible.builtin.combine(pkgconfig.luals) }}"
- name: Linux specific configuration
when:
- ansible_os_family != 'Darwin'
block:
- name: Load lua-language-server config
ansible.builtin.include_vars:
file: lua-language-server.yml
name: _luals
- name: Combine loaded config with defaults
ansible.builtin.set_fact:
pkgconfig_luals: "{{ _luals | ansible.builtin.combine(pkgconfig.luals) }}"
- name: append to pkgs
- name: Append to pkgs
ansible.builtin.set_fact:
srcpkgs: "{{ srcpkgs + ['lua-language-server'] }}"
- name: Append to syspkgs
when:
- ansible_os_family == 'Darwin'
ansible.builtin.set_fact:
srcpkgs: "{{ srcpkgs + [ 'lua-language-server' ] }}"
syspkgs: "{{ syspkgs + ['lua-language-server'] }}"