should have all the variables needed

This commit is contained in:
Matthew Stobbs
2026-01-25 01:38:28 -07:00
parent 7b8eaf35b7
commit fc0f6e6a82
5 changed files with 120 additions and 66 deletions

View File

@@ -21,13 +21,13 @@ argument_specs:
elements: str
description:
- Extra system packages by installation name to install using the system package manager
default_flatpak_method:
flatpak_method:
type: str
default: system
description:
- Default installation method for flatpaks.
- Possible values are 'system' and 'user'
default_install_method:
install_method:
type: str
default: system
choices:
@@ -41,18 +41,55 @@ argument_specs:
- Default installation method for packages.
- Varies between each indivdual package, but this is for overall package installation.
- Possible values are V(system), V(source), V(appimage), V(flatpak), V(cask), V(snap)
default_install_prefix:
install_prefix:
type: path
default: /usr/local
description:
- Default installation prefix when installation non-system packages.
path_suffix_appimage:
store_path:
type: path
default: "{{ default_install_prefix }}/appimage"
default: ANSIBLE_USER_DIR/.cache/ansible_role_package
description:
- Where to store cached files like archives and git repos
clean_source:
type: bool
default: false
description:
- Remove existing installation of package before installing
path_appimage:
type: path
default: INSTALL_PREFIX/appimage
description:
- Where appimage files are stored.
path_suffix_archive:
path_archive:
type: path
default: "{{ default_install_prefix }}/archive"
default: INSTALL_PREFIX/archive
description:
- Where archives are downloaded and extracted.
- Where archives are extracted.
path_bin:
type: path
default: INSTALL_PREFIX/bin
description:
- Where binaries are installed or linked.
- Needs to be added to your PATH
path_cargo:
type: path
default: INSTALL_PREFIX/cargo
description:
- Where cargo installs it's packages
path_go:
type: path
default: INSTALL_PREFIX/go
description:
- Where go is installed. Equivalent of GOROOT.
path_pipx:
type: path
default: INSTALL_PREFIX/pipx
description:
- Where pipx installs it's virtual environments
use_become:
type: bool
default: true
description:
- Elevate privileges when installing non-system packages.
- Building will be done as the ansible user, elevating only when installing.

View File

@@ -12,12 +12,10 @@ galaxy_info:
platforms:
- name: Fedora
versions:
- all
- "40"
- "41"
- "41+"
- name: EL
versions:
- "9"
- "9+"
- name: macOS
version:
- ">=14.2"

View File

@@ -12,54 +12,58 @@
ansible.builtin.set_fact:
package_home_base: /home
- name: Set local path prefix
when:
- use_local
- name: Set defaults paths
ansible.builtin.set_fact:
path:
prefix: "{{ package_home_base }}/{{ ansible_ssh_user }}/.local"
- name: Set non-local path prefix
when:
- not use_local
ansible.builtin.set_fact:
path:
prefix: "{{ default_install_prefix }}"
install_prefix: "{{ install_prefix | default(default_install_prefix) }}"
default_store_path: "{{ ansible_user_dir }}/.cache/ansible_role_package"
default_path_appimage: "{{ install_prefix | default(default_install_prefix) }}/appimage"
default_path_archive: "{{ install_prefix | default(default_install_prefix) }}/archive"
default_path_bin: "{{ install_prefix | default(default_install_prefix) }}/bin"
default_path_cargo: "{{ install_prefix | default(default_install_prefix) }}/cargo"
default_path_go: "{{ install_prefix | default(default_install_prefix) }}/go"
default_path_pipx: "{{ install_prefix | default(default_install_prefix) }}/pipx"
- name: Set install variables
ansible.builtin.set_fact:
ext_become: "{{ not use_local }}"
path:
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) }}"
cargo: "{{ path.cargo | default(path.prefix ~ defaults.path.suffix.cargo) }}"
go: "{% if ansible_distribution == 'MacOSX' %}/usr/local/go{% else %}{{ path.go | default(path.prefix ~ defaults.path.suffix.go) }}{% endif %}"
pipx: "{{ path.pipx | default(path.prefix ~ defaults.path.suffix.pipx) }}"
store_path: "{{ store_path | default(default_store_path) }}"
path_appimage: "{{ path_appimage | default(default_path_appimage) }}"
path_archive: "{{ path_archive | default(default_path_archive) }}"
path_bin: "{{ path_bin | default(default_path_bin) }}"
path_cargo: "{{ path_cargo | default(default_path_cargo) }}"
path_go: "{{ path_go | default(default_path_go) }}"
path_pipx: "{{ path_pipx | default(default_path_pipx) }}"
- name: Set OS independant facts
ansible.builtin.set_fact:
pkg_archive: [] # packages installed via prebuilt archive
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_src: [] # packages built from source
pkg_sys: [] # system package manager packages, homebrew on macOS, dnf for RedHat based, apt for Debian Based
pkg_zig: [] # zig packages
- name: Set Linux specific facts
when:
- ansible_system == 'Linux'
ansible.builtin.set_fact:
flatpak_remote: # flatpak remotes, includes flathub by default
- name: flathub
url: https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak_remotes: "{{ default_flatpak_remotes }}"
pkg_appimage: [] # appimages to install
pkg_flatpak: [] # flatpak packages to install
pkg_snap: [] # snpacraft.io packages
pipx_exec: "/usr/bin/pipx"
sys_pkg_become: true # Linux package managers require sudo access
lib_path: lib64
path_lib: lib64
root_prefix: /usr/local
- name: Set alpine linux specific facts
when:
- ansible_os_family == 'Alpine'
ansible.builtin.set_fact:
lib_path: lib
path_lib: lib
- name: Set rpm dist if RedHat based
- name: Set dist code if RedHat based
when:
- ansible_os_family == 'RedHat'
changed_when: false
@@ -76,17 +80,4 @@
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 # 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 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: [] # 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
path_lib: lib # macos shared library path

View File

@@ -2,12 +2,14 @@
---
# create all the facts used throughout the role, but shouldn't be touched
# by the user
- name: Create temporary directory for downloads
register: d_tempdir
- name: Create cache directory
register: d_cache
ansible.builtin.file:
path: /tmp/ansible_role_package
state: directory
path: "{{ store_path }}"
mode: '0777'
owner: "{{ ansible_user_id }}"
group: "{{ ansible_user_gid }}"
state: directory
- name: Set installation facts
ansible.builtin.include_tasks:

View File

@@ -2,20 +2,31 @@
# variables used in ansible_role_package
---
default_flatpak_method: system
default_flatpak_remotes:
- name: flathub
url: https://dl.flathub.org/repo/flathub.flatpakrepo
default_flatpak_remote_name: flathub
default_install_method: system
default_install_prefix: /usr/local
debug: false
default_store_path: HOME/.cache/ansible_role_package
default_path_appimage: /usr/local/appimage
default_path_archive: /usr/local/archive
default_path_bin: /usr/local/bin
default_path_cargo: /usr/local/cargo
default_path_go: /usr/local/go
default_path_pipx: /usr/local/pipx
default_path_git: /usr/local/git
packages: [] # list of packages to install
extra_packages: [] # list of extra packages to add to pkg_sys
# Path suffixes for installation types. Prefixed by `default_install_prefix`
path_suffix_appimage: appimage
path_suffix_archive: archive
path_suffix_bin: bin
path_suffix_cargo: cargo
path_suffix_go: go
path_suffix_pipx: pipx
path_suffix_source: source
directory_appimage: appimage
directory_archive: archive
directory_bin: bin
directory_cargo: cargo
directory_go: go
directory_pipx: pipx
directory_git: git
default_clean_source: false
@@ -27,3 +38,18 @@ _pkgconfig_force_rebuild: false
# neovim configuration
_pkgversion_neovim: master
_gitbranch_neovim: master
# Empty variables that need to exist
flatpak_remotes: null # flatpak remotes to add instead of default
flatpak_remote_name: null # the source of flatpak installations
flatpak_method: null # the method to use when installing flatpak
install_method: null # the way to install packages (system, source, etc)
install_prefix: null # the path prefix to install files
store_path: null # the path to store archives, git repos and appimages, etc.
path_appimage: null
path_archive: null
path_bin: null
path_cargo: null
path_go: null
path_pipx: null
use_become: true