working on helpers

This commit is contained in:
Matthew Stobbs
2026-02-05 17:18:02 -07:00
parent e231c6ae7a
commit e91e7e9698
12 changed files with 170 additions and 147 deletions

View File

@@ -19,7 +19,7 @@ up the correct linter and language server when using neovim/vim.
### Metadata ### Metadata
The metadata consists of at minimum 6 key: value pairs The metadata consists of `key: value` pairs, at minimum requiring:
```yaml ```yaml
# Package: <package name> # Package: <package name>
@@ -32,6 +32,35 @@ The metadata consists of at minimum 6 key: value pairs
This list should match package defaults where it makes sense, for example, This list should match package defaults where it makes sense, for example,
the `Version:` should match the default installed version of the package. the `Version:` should match the default installed version of the package.
### Default configuration
Default, non-computed configuration must exist in `vars/main.yml`, generally consisting of
the default version, urls, internal dependencies (internal to Ansible package manager) and
list of files installed after a build, without the `install_prefix`.
When adding default configuration, it MUST match the following:
- Surround the configuration in `# {{{ <package> configuration` and `# }}}`
- Where "package" is the name of the package
- Prefix the configuration with the name of the package, using snake case
- Example: `alacritty_version: v0.16.1`
- This keeps the configuration unique per package, and allows for the defaults
to be over-ridden where needed.
The things that should be in the default configuration, if relevant, are:
- Default version, as `<package>_version`
- Git repository for pulling the source as `<package>_git_repo`
- Archive URL as `<package>_archive_url`
- Internal dependecies as `<package>_pkg_deps: <list of internal dependencies>`
- Files installed when building from source as `<package>_build_files`
- Default compile flags for the build system.
- Example using cargo: `<package>_cargo_build_flags: <list of build flags>`
- Package build dependencies per ansible_os_family. These are only for system
packages that are required for building the package from source.
- Package runtime dependencies as `<package>_run_deps: <list of run dependencies>`
- These should only be system packages, not internal packages
### Configuration acknowledgement ### Configuration acknowledgement
The "Configuration acknowledgement" MUST be at the start of the yaml file, The "Configuration acknowledgement" MUST be at the start of the yaml file,
@@ -50,15 +79,7 @@ It looks like this, using the `air` package:
- name: Finalize air configuration - name: Finalize air configuration
ansible.builtin.set_fact: ansible.builtin.set_fact:
__air_configured: true __configured: "{{ __configured | combine( { 'air': true } ) }}"
```
or alternatively:
```yaml
- name: Start air configuration
when:
- __configured['air'] is undefined
``` ```
This way, if a package is included as part of another packages build, it only happens once. This way, if a package is included as part of another packages build, it only happens once.
@@ -68,17 +89,44 @@ This way, if a package is included as part of another packages build, it only ha
Adding the configuration for a package is done by appending the configuration to the Adding the configuration for a package is done by appending the configuration to the
appropriate list. Each helper has it's own installation block in `tasks/main.yml`. appropriate list. Each helper has it's own installation block in `tasks/main.yml`.
Depending on the package installation method, the package must be added to the appropriate list. Depending on the package installation method, the package must be added to the
appropriate list.
#### Different lists, and when to use them #### Different lists, and when to use them
The following is a list of the different lists that are used, and the The following is a list of the different lists that are used, and the
order they are run. order they are run.
- system: pkg_sys ##### System packages
- Only for packages installed from the system package manager
- If a package adds a repository to handle the system installation, it should be
done in the package configuration itself. For example, installing `ghostty` via
the system package manager requires adding a copr repo on fedora. This should be
done in a section named 'Adding copr repository scottames/ghostty'
pkg_sys: List of system package manager packages to install
- Installed using `ansible.builtin.package`
- Installs the entire gathered list of packages at once, instead of looping over single items.
- The package list is made unique by applying the `unique` filter to the list
##### Archive packages
Archive packages are binaries installed by extracting an archive and linking the files
in place (usually in `<install_prefix>/bin`).
- Archives are kept in a cache after download, unless `clean_cache` is `true`
- Extracted archives are placed in `<install_prefix>/archive/<name>`
- Archive files are linked to the appropriate place under `install_prefix`, as dictated by
the `pkg.links` list, where `pkg` is the top level dict object of the archive
2. pkg_archive: List of packages installed via archive, like `go`
- Loops over list of archives and downloads, extracts and links them before moving
on to the next.
3. Linux only packages. Flatpaks, appimages, and snapcraft packages.
- Flatpaks: use the lists `flatpak_remotes` and `pkg_flatpak`
- `flatpak_remotes` is a list of dicts containing the flatpak remote configurations
- Managed using `community.general.flatpak_remote` ansible module.
- Format is:
```yaml
remote:
name: <remote name>
url: <flatpakrepo url>
method: <optional, either 'system' or 'user'
```
- `pkg_flatpak` is a list of dicts

View File

@@ -1,6 +1,6 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
- name: Load firefox pkgconfig - name: Load firefox pkgconfig
ansible.bulitin.set_fact: ansible.builtin.set_fact:
firefox: firefox:
method: "{{ pkgconfig.firefox.method[ansible_os_family] | default(pkgconfig.firefox.method.default) }}" method: "{{ pkgconfig.firefox.method[ansible_os_family] | default(pkgconfig.firefox.method.default) }}"

View File

@@ -11,7 +11,7 @@
- name: Ensure directory exists - name: Ensure directory exists
become: "{{ install_become }}" become: "{{ install_become }}"
become_user: "{{ install_become_user }}" become_user: "{{ install_become_user }}"
ansible.bulitin.file: ansible.builtin.file:
state: directory state: directory
path: "{{ pkg.extract_to }}" path: "{{ pkg.extract_to }}"
mode: "{{ pkg.mode | default('0755') }}" mode: "{{ pkg.mode | default('0755') }}"
@@ -20,25 +20,29 @@
- name: Download archive to cache - name: Download archive to cache
ansible.builtin.get_url: ansible.builtin.get_url:
dest: "{{ d_cache }}/{{ pkg.name }}" dest: "{{ d_cache.path }}/{{ pkg.name }}"
url: "{{ pkg.url }}" url: "{{ pkg.url }}"
checksum: "{{ pkg.checksum | default(omit) }}" checksum: "{{ pkg.checksum | default(omit) }}"
decompress: false decompress: false
mode: '0644' mode: '0644'
- name: Extract archive - name: Extract archive
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
ansible.builtin.unarchive: ansible.builtin.unarchive:
dest: "{{ pkg.extract_to }}" dest: "{{ pkg.extract_to }}"
src: "{{ d_cache }}/{{ pkg.name }}" src: "{{ d_cache.path }}/{{ pkg.name }}"
remote_src: true remote_src: true
include: "{{ pkg.include | default(omit) }}" include: "{{ pkg.include | default(omit) }}"
exclude: "{{ pkg.exclude | default(omit) }}" exclude: "{{ pkg.exclude | default(omit) }}"
- name: Symlink archive files - name: Symlink archive files
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
when: when:
- pkg.bins is defined - pkg.links is defined
- pkg.bins | length > 0 - pkg.links | length > 0
loop: pkg.bins loop: "{{ pkg.links }}"
loop_control: loop_control:
loop_var: lnk loop_var: lnk
ansible.builtin.file: ansible.builtin.file:

View File

@@ -1,9 +1,10 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
- name: Install flatpak - name: Install flatpak
become: "{{ ext_become }}" become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
community.general.flatpak: community.general.flatpak:
method: "{{ pkg_method }}" method: "{{ flatpak.method | default('system') }}"
remote: "{{ pkg_remote }}" remote: "{{ flatpak.remote }}"
name: "{{ pkg_name }}" name: "{{ flatpak.name }}"
state: present state: "{{ flatpak.state | default('present') }}"

View File

@@ -1,10 +1,11 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
- name: Add flatpak remote - name: Add flatpak remote
become: "{{ ext_become }}" become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
community.general.flatpak_remote: community.general.flatpak_remote:
enabled: "{{ remote_enabled }}" enabled: "{{ remote.enabled | default(true) }}"
flatpakrepo_url: "{{ remote_url }}" flatpakrepo_url: "{{ remote.url }}"
method: "{{ remote_method }}" method: "{{ remote.method | default('system') }}"
name: "{{ remote_name }}" name: "{{ remote.name }}"
state: "{{ remote_state }}" state: "{{ remote.state | default('present') }}"

View File

@@ -7,15 +7,9 @@
- name: Add flatpak remotes - name: Add flatpak remotes
when: when:
- flatpak_remote|length > 0 - flatpak_remote|length > 0
loop: "{{ flatpak_remote | unique }}" loop: "{{ flatpak_remotes }}"
loop_control: loop_control:
loop_var: remote loop_var: remote
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: ansible.builtin.include_tasks:
file: helpers/flatpak_remote.yml file: helpers/flatpak_remote.yml

View File

@@ -1,5 +1,9 @@
# vim: set filetype=yaml.ansible : # vim: set filetype=yaml.ansible :
--- ---
- name: Show indev warning
ansible.builtin.debug:
msg: "This software is in development. Use at your own risk"
- name: Set installation facts - name: Set installation facts
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: facts.yml file: facts.yml
@@ -137,11 +141,21 @@
file: addpkg.yml file: addpkg.yml
- name: Install sys_pkgs list using system package manager - name: Install sys_pkgs list using system package manager
become: "{{ sys_pkg_become }}" become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
ansible.builtin.package: ansible.builtin.package:
name: "{{ pkg_sys | unique }}" name: "{{ pkg_sys | unique }}"
state: present state: present
- name: Install pkg_archive
when:
- pkg_archive|length > 0
loop: "{{ pkg_archive }}"
loop_control:
loop_var: pkg
ansible.builtin.include_tasks:
file: helpers/archive.yml
- name: Linux specific tasks - name: Linux specific tasks
when: when:
- ansible_system == 'Linux' - ansible_system == 'Linux'
@@ -154,15 +168,6 @@
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: macos.yml file: macos.yml
- name: Install pkg_archive
when:
- pkg_archive|length > 0
loop: "{{ pkg_archive }}"
loop_control:
loop_var: pkg
ansible.builtin.include_tasks:
file: "helpers/archive.yml"
- name: Install cargo packages - name: Install cargo packages
when: when:
- pkg_cargo|length > 0 - pkg_cargo|length > 0
@@ -238,11 +243,3 @@
loop_var: pkg loop_var: pkg
ansible.builtin.include_tasks: ansible.builtin.include_tasks:
file: "src/{{ pkg }}.yml" file: "src/{{ pkg }}.yml"
- name: Cleanup {{ d_tempdir.path }}
become: true
when:
- not debug
ansible.builtin.file:
state: absent
path: "{{ d_tempdir.path }}"

View File

@@ -8,7 +8,7 @@
- name: Set ansible install method - name: Set ansible install method
when: when:
- ansible_install_method is undefined - ansible_install_method is undefined
ansible.bulitin.set_fact: ansible.builtin.set_fact:
ansible_install_method: "{% if install_method in ansible_install_methods %}{{ install_method }}{% else %}{{ ansible_install_methods[0] }}{% endif %}" ansible_install_method: "{% if install_method in ansible_install_methods %}{{ install_method }}{% else %}{{ ansible_install_methods[0] }}{% endif %}"
ansible_pkgname: ansible_pkgname:
RedHat: ansible RedHat: ansible

View File

@@ -2,7 +2,7 @@
--- ---
- name: Configure go for install - name: Configure go for install
when: when:
- __go_configured is undefined - "'go' not in __configured"
block: block:
- name: Configure go install method - name: Configure go install method
when: when:
@@ -14,23 +14,15 @@
when: when:
- go_install_method == 'system' - go_install_method == 'system'
block: block:
- name: Set go pkgname for linux - name: Set go pkgname
when:
- ansible_system == 'Linux'
ansible.builtin.set_fact: ansible.builtin.set_fact:
go_pkgname: "{{ go_pkgname[ansible_os_family] }}" go_pkgname: "{{ go_pkgname[ansible_os_family] }}"
- name: Set go pkgname for FreeBSD - name: Set go pkgname for FreeBSD
when: when:
- ansible_os_family == 'FreeBSD' - ansible_os_family == 'FreeBSD'
ansible.bulitin.set_fact:
go_pkgname: "{{ go_pkgname[ansible_os_family][go_bsd_version] | default(go_pkgname[ansible_os_family]['default']) }}"
- name: Set go pkgname for Darwin/MacOS
when:
- ansible_os_family == 'Darwin'
ansible.builtin.set_fact: ansible.builtin.set_fact:
go_pkgname: "{{ go_pkgname[ansible_os_family] }}" go_pkgname: "{{ go_pkgname[go_bsd_version] | default(go_pkgname['default']) }}"
- name: Configure go archive installation - name: Configure go archive installation
when: when:
@@ -39,10 +31,7 @@
- name: Configure go - name: Configure go
ansible.builtin.set_fact: ansible.builtin.set_fact:
go_system: "{{ ansible_system | lower }}" go_system: "{{ ansible_system | lower }}"
go_arch: "{{ go_archive_archmap[ansible_architecture] }}"
- name: Set go architecture
ansible.builtin.set_fact:
go_arch: "{{ go_archmap[ansible_architecture] }}"
- name: Set archive name - name: Set archive name
ansible.builtin.set_fact: ansible.builtin.set_fact:
@@ -50,7 +39,7 @@
- name: Set go archive url and path - name: Set go archive url and path
ansible.builtin.set_fact: ansible.builtin.set_fact:
go_archive_url: "https://go.dev/dl/{{ go_archive_file }}" go_archive_url: "{{ go_archive_url_base }}/{{ go_archive_file }}"
go_extract_path: "{{ path_archive }}/go{{ go_archive_version }}" go_extract_path: "{{ path_archive }}/go{{ go_archive_version }}"
- name: Finalize go archive install - name: Finalize go archive install
@@ -58,15 +47,14 @@
go_archive_install: go_archive_install:
extract_to: "{{ go_extract_path }}" extract_to: "{{ go_extract_path }}"
url: "{{ go_archive_url }}" url: "{{ go_archive_url }}"
name: "{{ go_archive }}" name: "{{ go_archive_file }}"
checksum: "{{ go_archive_sums[go_archive_version][ansible_system][go_arch] }}" checksum: "{{ go_archive_sums[go_archive_version][ansible_system][go_arch] }}"
bins: links:
- from: "{{ go_archive_path }}/go" - from: "{{ go_extract_path }}/go"
to: "{{ path_go }}" to: "{{ path_go }}"
force: true force: true
- from: "{{ path_go }}/bin/go" __add_to_path: "{{ __add_to_path + [path_go ~ '/bin'] }}"
to: "{{ path_bin }}/go" __var_to_env: "{{ __var_to_env | combine( { 'GOROOT': path_go } ) }}"
force: true
- name: Queue go install - name: Queue go install
block: block:
@@ -84,13 +72,6 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
pkg_archive: "{{ pkg_archive + [go_archive_install] }}" pkg_archive: "{{ pkg_archive + [go_archive_install] }}"
- name: Set symbolic link to archive path
ansible.bulitin.file:
state: link
force: true
path: "{{ path_go }}"
src: "{{ go_extract_path }}/go"
- name: Complete go archive install configuration - name: Complete go archive install configuration
ansible.builtin.set_fact: ansible.builtin.set_fact:
__go_configured: true __configured: "{{ __configured | combine( { 'go': true } ) }}"

View File

@@ -7,13 +7,13 @@
- name: Set Hyprland install method - name: Set Hyprland install method
when: when:
- hyprland_install_method is undefined - hyprland_install_method is undefined
ansible.bulitin.set_fact: ansible.builtin.set_fact:
hyprland_install_method: "{% if install_method in hyprland_install_methods %}{{ install_method }}{% else %}{{ hyprland_install_methods[0] }}{% endif %}" hyprland_install_method: "{% if install_method in hyprland_install_methods %}{{ install_method }}{% else %}{{ hyprland_install_methods[0] }}{% endif %}"
- name: Set Hyprland source install configuration - name: Set Hyprland source install configuration
when: when:
- hyprland_install_method == 'source' - hyprland_install_method == 'source'
ansible.bulitin.set_fact: ansible.builtin.set_fact:
hyprland_version: "{{ hyprland_version | default('v0.53.3') }}" hyprland_version: "{{ hyprland_version | default('v0.53.3') }}"
hyprland_git_repo: "{{ hyprland_git_repo | default('https://github.com/hyprwm/Hyprland') }}" hyprland_git_repo: "{{ hyprland_git_repo | default('https://github.com/hyprwm/Hyprland') }}"
hyprland_build_deps: hyprland_build_deps:

View File

@@ -51,16 +51,18 @@ pkg_src: [] # packages built from source
pkg_sys: [] # system package manager packages pkg_sys: [] # system package manager packages
pkg_sys_pip: [] # system pip packages pkg_sys_pip: [] # system pip packages
pkg_zig: [] # zig packages pkg_zig: [] # zig packages
__configured: [] # list of configured packages __configured: {} # dict of configured packages
__add_to_path: [] # list of paths that should be in PATH
__var_to_env: {} # dict of variables to add to your env
# Per package variables # Per package variables
## {{{ air ## {{{ air
air_version: latest air_version: latest
air_build_files:
- bin/air
air_install_url: github.com/air-verse/air air_install_url: github.com/air-verse/air
air_pkg_deps: air_pkg_deps:
- pkgs/go.yml - pkgs/go.yml
air_build_files:
- bin/air
# }}} # }}}
## {{{ alacritty ## {{{ alacritty
alacritty_version: v0.16.1 alacritty_version: v0.16.1
@@ -133,6 +135,7 @@ go_archive_archmap:
arm64: arm64 arm64: arm64
aarch64: arm64 aarch64: arm64
x86_64: amd64 x86_64: amd64
go_archive_url_base: https://go.dev/dl
go_archive_sums: go_archive_sums:
1.25.6: 1.25.6:
Darwin: Darwin:

View File

@@ -1,6 +0,0 @@
# vim: set filetype=yaml.ansible :
---
maintainers:
- name: Matthew Stobbs
packages:
- all