Modifying default variables and config

Renamed variables for defaults:
- flatpak_method -> default_flatpak_method: system
- defaults.paths.prefix -> default_install_prefix: /usr/local
New variables:
- default_install_method: package
This commit is contained in:
Matthew Stobbs
2026-01-24 19:52:56 -07:00
parent fe364e2b6d
commit e021d5ebac
15 changed files with 85 additions and 53 deletions

View File

@@ -24,13 +24,13 @@
- not use_local
ansible.builtin.set_fact:
path:
prefix: "{{ defaults.path.prefix }}"
prefix: "{{ default_install_prefix }}"
- name: Set install variables
ansible.builtin.set_fact:
ext_become: "{{ not use_local }}"
path:
prefix: "{{ path.prefix }}"
prefix: "{{ default_install_prefix }}"
appimage: "{{ path.appimage | default(path.prefix ~ defaults.path.suffix.appimage) }}"
archive: "{{ path.archive | default(path.prefix ~ defaults.path.suffix.archive) }}"
bin: "{{ path.bin | default(path.prefix ~ defaults.path.suffix.bin) }}"
@@ -45,7 +45,6 @@
flatpak_remote: # flatpak remotes, includes flathub by default
- name: flathub
url: https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak_method: "{% if use_local %}user{% else %}system{% endif %}"
pkg_appimage: [] # appimages to install
pkg_flatpak: [] # flatpak packages to install
pkg_snap: [] # snpacraft.io packages
@@ -70,22 +69,24 @@
- name: Set macOS specific facts
when:
- ansible_distribution == 'MacOSX'
- ansible_distribution == 'MacOSX' or
ansible_distribution == 'MacOS'
ansible.builtin.set_fact:
brewtap: [] # homebrew taps to add
pipx_exec: "/opt/homebrew/bin/pipx"
pipx_exec: "/opt/homebrew/bin/pipx" # pipx executable
pkg_cask: [] # homebrew casks
pkg_tap: [] # homebrew tap packages
sys_pkg_become: false # homebrew doesn't require sudo access
lib_path: lib
lib_path: lib # macos shared library path
- name: Set OS independant facts
ansible.builtin.set_fact:
pkg_archive: [] # packages installed via prebuilt archive
pkg_cargo: [] # rust packages from cargo
pkg_cargo: [] # rust packages from cargo using `cargo install`
pkg_cargo_build: [] # rust packages using `cargo build` before install
pkg_go: [] # go applications
pkg_npm: [] # npm commands
pkg_pipx: [] # pipx packages
pkg_zig: []
pkg_zig: [] # zig packages
pkg_src: [] # packages built from source
pkg_sys: [] # system package manager packages, homebrew on macOS, dnf for RedHat based, apt for Debian Based

View File

@@ -5,7 +5,7 @@
block:
- name: Ensure appimage path exists
ansible.builtin.file:
path: "{{ path.appimage }}/{{ pkg.link_name }}"
path: "{{ path.appimage }}/{{ appimage_link_name }}"
mode: '0755'
state: directory
@@ -15,12 +15,12 @@
mode: '0755'
decompress: false
backup: true
url: "{{ pkg.url }}"
dest: "{{ path.appimage }}/{{ pkg.link_name }}/{{ pkg.file }}"
url: "{{ appimage_url }}"
dest: "{{ path.appimage }}/{{ appimage_link_name }}/{{ appimage_file }}"
- name: Link appimage to bin
become: "{{ ext_become }}"
ansible.builtin.file:
state: link
src: "{{ path.appimage }}/{{ pkg.link_name }}/{{ pkg.file }}"
path: "{{ path.bindir }}/{{ pkg.link_name }}"
src: "{{ path.appimage }}/{{ appimage_link_name }}/{{ appimage_file }}"
path: "{{ path.bindir }}/{{ appimage_link_name }}"

View File

@@ -50,6 +50,7 @@
group: root
mode: "0755"
state: directory
- name: Copy extra files
loop: "{{ install_files | dict2items }}"
loop_control:

View File

@@ -0,0 +1,9 @@
# vim: set filetype=yaml.ansible :
---
- name: Install flatpak
become: "{{ ext_become }}"
community.general.flatpak:
method: "{{ pkg_method }}"
remote: "{{ pkg_remote }}"
name: "{{ pkg_name }}"
state: present

View File

@@ -0,0 +1,10 @@
# vim: set filetype=yaml.ansible :
---
- name: Add flatpak remote
become: "{{ ext_become }}"
community.general.flatpak_remote:
enabled: "{{ remote_enabled }}"
flatpakrepo_url: "{{ remote_url }}"
method: "{{ remote_method }}"
name: "{{ remote_name }}"
state: "{{ remote_state }}"

View File

@@ -7,37 +7,42 @@
- name: Add flatpak remotes
when:
- flatpak_remote|length > 0
become: "{{ ext_become }}"
loop: "{{ flatpak_remote | unique }}"
loop_control:
loop_var: remote
community.general.flatpak_remote:
enabled: true
flatpakrepo_url: "{{ remote.url }}"
method: "{{ flatpak_method }}"
name: "{{ remote.name }}"
state: present
vars:
remote_enabled: true
remote_url: "{{ remote.url }}"
remote_method: "{{ remote.method | default(default_flatpak_method) }}"
remote_name: "{{ remote.name }}"
remote_state: "{{ remote.state | default('present') }}"
ansible.builtin.include_tasks:
file: helpers/flatpak_remote.yml
- name: Install flatpaks
when:
- pkg_flatpak|length > 0
become: "{{ ext_become }}"
block:
- name: Install flatpak
loop: "{{ pkg_flatpak | unique }}"
loop_control:
loop_var: flatpak
community.general.flatpak:
method: "{{ flatpak.method | default(flatpak_method) }}"
name: "{{ flatpak.name | default(flatpak) }}"
remote: "{{ flatpak.remote | default('flathub') }}"
state: present
vars:
pkg_method: "{{ flatpak.method | default(default_flatpak_method) }}"
pkg_remote: "{{ flatpak.remote | default(default_flatpak_remote) }}"
pkg_name: "{{ flatpak.name | default(flatpak) }}"
ansible.builtin.include_tasks:
file: helpers/flatpak.yml
- name: Install pkg_appimage
when:
- pkg_appimage|length > 0
loop: "{{ pkg_appimage }}"
loop_control:
loop_var: pkg
loop_var: appimage
vars:
appimage_link_name: "{{ appimage.link_name }}"
appimage_url: "{{ appimage.url }}"
appimage_file: "{{ appimage.file }}"
ansible.builtin.include_tasks:
file: appimage.yml
file: helpers/appimage.yml

View File

@@ -198,6 +198,26 @@
ansible.builtin.include_tasks:
file: cargo.yml
- name: Build and install rust apps
when:
- pkg_cargo_build|length > 0
block:
- name: Run cargo build and install
loop: "{{ cargo_pkg_build }}"
loop_control:
loop_var: pkg
vars:
bin_name: "{{ pkg.bin_name | default(omit) }}"
bin_output: "{{ pkg.bin_output | default(omit) }}"
cargo_build_flags: "{{ pkg.cargo_build_flags | default(omit) }}"
depth: "{{ pkg.depth | default(omit) }}"
install_files: "{{ pkg.install_files | default(omit) }}"
name: "{{ pkg.name | default(omit) }}"
recursive: "{{ pkg.recursive | default(omit) }}"
repo: "{{ pkg.repo | default(omit) }}"
ansible.builtin.include_tasks:
file: helpers/cargo_build.yml
- name: Install go packages
when:
- pkg_go|length > 0

View File

@@ -32,7 +32,6 @@
ansible.builtin.set_fact:
alacritty_method: source
alacritty_src_install:
cargo_install_type: source
cargo_build_flags:
- --release
name: "{{ alacritty_pkgname }}"
@@ -97,7 +96,6 @@
- python3
- desktop-file-utils
# }}}
- name: Append alacritty installation
block:
- name: Append alacritty to pkg_cargo

View File

@@ -1,24 +1,22 @@
# vim: set filetype=yaml.ansible :
# variables used in ansible_role_package
---
default_install_method: package
default_flatpak_method: system # possible values are 'system' and 'user'
default_install_method: package # possible values are 'package', 'source', 'appimage'
default_install_prefix: /usr/local
debug: false
use_local: false
prefer_method: src
packages: [] # list of packages to install
extra_packages: [] # list of extra packages to add to pkg_sys
go_do_update: true
defaults:
path:
prefix: "/usr/local"
paths:
suffix:
appimage: "/appimage" # keep appimages here
archive: "/archive" # extract archives here
bin: "/bin" # installation prefix. Binaries are placed in `{{ install }}/bin`
cargo: "/cargo" # cargo install location
go: "/go" # GOROOT
pipx: "/pipx" # where pipx environments are installed (venvs). They are symlinked to `bin`
appimage: "/appimage" # keep appimages in `{{ default_install_prefix }}/appimage`
archive: "/archive" # extract archives to `{{ default_install_prefix }}/archive`
bin: "/bin" # installation prefix. Binaries are placed in `{{ default_install_prefix }}/bin`
cargo: "/cargo" # cargo install location `{{ default_install_prefix }}/cargo`
go: "/go" # GOROOT `{{ default_install_prefix }}/go`
pipx: "/pipx" # where pipx environments are installed `{{ default_install_prefix }}/pipx`
# paths resolve to either $HOME/.local as the prefix, or /usr/local
# all created paths are named:

View File

@@ -1,10 +0,0 @@
# vim: set filetype=yaml.ansible :
---
alacritty:
version: 0.15.1
method:
default: cargo
Darwin: cask
cargo:
locked: true
name: alacritty