working on cleanup and fixing a few format issues

- modifying how installs are done
This commit is contained in:
Matthew Stobbs
2026-02-15 17:57:05 -07:00
parent b1a4780a97
commit e39c3b7046
11 changed files with 201 additions and 139 deletions

View File

@@ -19,12 +19,18 @@
path_archive: "{{ install_prefix }}/archive"
path_bin: "{{ install_prefix }}/bin"
path_cargo: "{{ install_prefix }}/cargo"
path_git: "{{ install_prefix }}/git"
path_source: "{{ install_prefix }}/source"
path_go: "{{ install_prefix }}/go"
path_pipx: "{{ install_prefix }}/pipx"
store_path: "{{ ansible_facts['user_dir'] }}/.cache/ansible_role_package"
path_lib: "{{ install_prefix }}/lib"
- name: Set install_become_group from install_become_user
block:
- name: Get install_become_user userinfo
ansible.builtin.getent:
database: passwd
key: "{{ install_become_user }}"
- name: Set Linux specific facts
when:

View File

@@ -4,48 +4,29 @@
block:
- name: Fetch git repo
vars:
git:
path: "{{ d_cache.path }}/{{ cargo_build.name }}"
repo: "{{ cargo_build.repo }}"
depth: "{{ cargo_build.depth | default(1) }}"
force: "{{ cargo_build.force_git | default(true) }}"
recursive: "{{ cargo_build.recursive | default(true) }}"
version: "{{ cargo_build.version | default(omit) }}"
ansible.builtin.include_tasks:
file: helpers/git.yml
path: "{{ path_source }}/{{ cargo_build.source_dir }}"
repo: "{{ cargo_build.repo }}"
depth: "{{ cargo_build.depth | default(1) }}"
force: "{{ cargo_build.force_git | default(true) }}"
recursive: "{{ cargo_build.recursive | default(true) }}"
version: "{{ cargo_build.version | default(omit) }}"
ansible.builtin.include_tasks: helpers/git.yml
- name: Build cargo release
ansible.builtin.command:
chdir: "{{ d_cache.path }}/{{ cargo_build.name }}"
chdir: "{{ path_source }}/{{ cargo_build.source_dir }}"
argv: "{{ [cargo, build] + cargo_build.build_flags }}"
- name: Clean existing install
vars:
files: "{{ cargo_build.files }}"
ansible.builtin.include_tasks: helpers/clean.yml
- name: Install cargo release
block:
- name: Create missing directories
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ cargo_build.files }}"
loop_control:
loop_var: file
ansible.builtin.file:
state: directory
path: "{{ install_prefix }}/{{ file.to | dirname }}"
mode: '0755'
owner: "{{ cargo_build.owner | default(ansible_user_id) }}"
group: "{{ cargo_build.group | default(ansible_user_gid) }}"
- name: Install release files
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ cargo_build.files }}"
loop_control:
loop_var: file
ansible.builtin.copy:
backup: false
remote_src: true
src: "{{ d_cache.path }}/{{ cargo_build.name }}/{{ file.from }}"
dest: "{{ install_prefix }}/{{ file.to }}"
owner: "{{ cargo_build.owner | default(ansible_user_id) }}"
group: "{{ cargo_build.group | default(ansible_user_gid) }}"
mode: "{{ file.mode | default('0644') }}"
force: "{{ file.force | default(true) }}"
vars:
source_dir: "{{ cargo_build.source_dir }}"
ansible.builtin.include_tasks: helpers/install.yml

View File

@@ -1,10 +1,21 @@
# vim: set filetype=yaml.ansible :
---
- name: Remove file list
become: true
loop: "{{ file_list }}"
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ files }}"
loop_control:
loop_var: file
when:
- file.to is defined
ansible.builtin.file:
state: absent
path: "{{ file }}"
path: "{{ install_prefix }}/{{ file.to }}"
- name: Check for and remove empty directories
loop: "{{ files }}"
loop_control:
loop_var: dir
when:
- file.directory is defined
ansible.builtin.include_tasks: internal/remove_empty_dir.yml

View File

@@ -2,9 +2,9 @@
---
- name: Clone git repository
ansible.builtin.git:
depth: "{{ git.depth | default(1) }}"
dest: "{{ git.path }}"
force: "{{ git.force | default(true) }}"
recursive: "{{ git.recursive | default(true) }}"
repo: "{{ git.repo }}"
version: "{{ git.version | default(omit) }}"
dest: "{{ path }}"
repo: "{{ repo }}"
depth: "{{ depth | default(1) }}"
force: "{{ force | default(true) }}"
recursive: "{{ recursive | default(true) }}"
version: "{{ version | default(omit) }}"

40
tasks/helpers/install.yml Normal file
View File

@@ -0,0 +1,40 @@
# vim: set filetype=yaml.ansible :
#
## Helper: install.yml
## Description: install files defined in dict
## Variables:
## _Note_ This is mutually exclusive to having a 'to' key
## - directory: path prefixed by {{ install_prefix }} of a directory to
## be created
## mode: _optional_, _default_ '0755'
##
## _Note_ This is mutually exclusive to having a 'directory' key
## - to: where to install file to, prefixed with {{ install_prefix }}
## from: source file from build path root for package
## mode: _optional_, _default_ '0644'##
##
## Notes: This is only used when copying files or creating directories
## for installing. If a source package doesn't require you to manually
## copy anthing (go install, as an example), don't use this.
---
- name: Create directories
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ pkg_clean }}"
loop_control:
loop_var: dir
when:
- dir.directory is defined
ansible.builtin.file:
state: directory
mode: '0755'
path: "{{ install_prefix }}/{{ dir.directory }}"
- name: Copy installable files
become: "{{ install_become }}"
become_user: "{{ install_become_user }}"
loop: "{{ pkg_clean }}"
ansible.builtin.copy:
dest: "{{ install_prefix }}/{{ file.to }}"
mode: "{{ file.mode | default('0644') }}"
src: "{{ file.builddir | default(omit) }}/"

View File

@@ -0,0 +1,16 @@
# vim: set filetype=yaml.ansible :
---
- name: Check if dir is empty
ansible.builtin.find:
paths:
- "{{ dir }}"
file_type: any
hidden: true
register: fd_empty
- name: Remove empty dir
when:
- fd_empty.matched|int == 0
ansible.builtin.file:
path: "{{ dir }}"
state: absent

View File

@@ -26,7 +26,7 @@
- "{{ path_archive }}"
- "{{ path_bin }}"
- "{{ path_cargo }}"
- "{{ path_git }}"
- "{{ path_source }}"
- "{{ path_pipx }}"
loop_control:
loop_var: path
@@ -70,6 +70,9 @@
ansible.builtin.include_tasks:
file: "pkgs/{{ pkg }}.yml"
- name: Clean installations that require it
ansible.builtin.include_tasks: "helpers/clean_install.yml"
- name: Install go if required
when:
- pkg_go|length > 0

View File

@@ -15,7 +15,7 @@
when:
- air_install_method is undefined
ansible.builtin.set_fact:
air_install_method: "{{ install_method if install_method in air_install_methods else air_install_methods[0] }}"
air_install_method: "{{ install_method if install_method in air.install_methods else air.install_methods[0] }}"
- name: Set air build facts
when:
@@ -27,6 +27,7 @@
url: "{{ air_install_url }}@{{ air_version }}"
bin: "{{ path_bin }}/air"
# }}}
# {{{ air build and install steps
- name: Append air to pkg_go
when:
- air_install_method == 'source'
@@ -34,23 +35,19 @@
- name: Clean existing air install
when:
- clean_install
loop: "{{ air_build_files }}"
loop_control:
loop_var: air_file
ansible.builtin.file:
state: absent
path: "{{ install_prefix }}/{{ air_file }}"
ansible.builtin.set_fact:
pkg_clean: "{{ pkg_clean + air.install_files }}"
- name: Configure pkg dependencies
loop: "{{ air_pkg_deps }}"
loop: "{{ air.pkg_deps }}"
loop_control:
loop_var: air_pkg_dep
ansible.builtin.include_tasks: "{{ air_pkg_dep }}"
loop_var: pkg
ansible.builtin.include_tasks: "pkgs/{{ pkg }}.yml"
- name: Add air to install list
ansible.builtin.set_fact:
pkg_go: "{{ pkg_go + [air_go_pkg] }}"
# }}}
- name: Finalize air configuration
ansible.builtin.set_fact:
__configured: "{{ __configured | combine( { 'air': true } ) }}"

View File

@@ -17,7 +17,7 @@
when:
- alacritty_install_method is undefined
ansible.builtin.set_fact:
alacritty_install_method: "{{ install_method if install_method in alacritty_install_methods else alacritty_install_methods[0] }}"
alacritty_install_method: "{{ install_method if install_method in alacritty.install_methods else alacritty.install_methods[0] }}"
- name: Configure alacritty source install
when:
@@ -25,20 +25,13 @@
block:
- name: Set alacritty build facts
ansible.builtin.set_fact:
alacritty_build_deps: "{{ alacritty_build_deps[ansible_os_family] }}"
alacritty_src_install:
build_deps: "{{ alacritty.build_deps[ansible_facts['os_family']] }}"
build_flags: "{{ alacritty_cargo_build_flags }}"
name: "{{ alacritty_pkgname }}"
source_dir: "{{ alacritty.install_files.source_dir }}"
repo: "{{ alacritty_git_repo }}"
version: "{{ alacritty_version }}"
files:
- from: target/release/alacritty
to: bin/alacritty
mode: '0755'
- from: extra/logo/alacritty-term.svg
to: share/pixmaps/Alacritty.svg
- from: extra/linux/Alacritty.desktop
to: share/applications/Alacritty.desktop
files: "{{ alacritty.install_files.files }}"
- name: Set alacritty install extra build deps
when:
@@ -49,13 +42,13 @@
when:
- ansible_distribution_major_version == 7
ansible.builtin.set_fact:
alacritty_build_deps: "{{ alacritty_build_deps + ['xcb-util-devel', '@Development Tools'] }}"
alacritty_build_deps: "{{ build_deps + ['xcb-util-devel', '@Development Tools'] }}"
- name: Add extra dependencies for EL8
when:
- ansible_distribution_major_version == 8
ansible.builtin.set_fact:
alacritty_build_deps: "{{ alacritty_build_deps + ['@Development Tools'] }}"
alacritty_build_deps: "{{ build_deps + ['@Development Tools'] }}"
# }}}
- name: Append alacritty installation
@@ -65,14 +58,14 @@
- alacritty_method == 'source'
block:
- name: Configure pkg dependencies
loop: "{{ alacritty_pkg_deps }}"
loop: "{{ alacritty.pkg_deps }}"
loop_control:
loop_var: alacritty_pkg_dep
ansible.builtin.include_tasks: "{{ alacritty_pkg_dep }}"
loop_var: pkg
ansible.builtin.include_tasks: "pkgs/{{ pkg }}.yml"
- name: Append build dependencies and cargo config
ansible.builtin.set_fact:
pkg_sys: "{{ pkg_sys + alacritty_build_deps }}"
pkg_sys: "{{ pkg_sys + build_deps }}"
pkg_cargo_build: "{{ pkg_cargo_build + [alacritty_src_install] }}"
- name: Append alacritty to pkg_sys