From b87fc8235e269596d061b1177d174bddcccc0362 Mon Sep 17 00:00:00 2001 From: Matthew Stobbs Date: Fri, 6 Feb 2026 01:28:14 -0700 Subject: [PATCH] fixing obvious errors --- CONTRIBUTING.md | 15 ++++-- tasks/helpers/appimage.yml | 28 +++++------ tasks/helpers/archive.yml | 34 ++++++------- tasks/helpers/cargo.yml | 6 +-- tasks/helpers/cargo_build.yml | 84 +++++++++++++------------------- tasks/helpers/flatpak.yml | 4 +- tasks/helpers/flatpak_remote.yml | 6 +-- tasks/linux.yml | 20 ++------ tasks/main.yml | 69 ++++++++++++-------------- tasks/pkgs/alacritty.yml | 64 +++++++++++------------- 10 files changed, 149 insertions(+), 181 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a30c529..fb73e30 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ When adding default configuration, it MUST match the following: - 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. + to be overridden where needed. The things that should be in the default configuration, if relevant, are: @@ -127,6 +127,15 @@ in place (usually in `/bin`). remote: name: url: - method: + ``` + - `pkg_flatpak` is a list of dicts describing how to install a flatpak + - Managed using `community.general.flatpak` ansible module. + - Format is: + ```yaml + flatpak: + name: + remote: + method: + state: ``` - - `pkg_flatpak` is a list of dicts diff --git a/tasks/helpers/appimage.yml b/tasks/helpers/appimage.yml index 3845f6e..aa472a4 100644 --- a/tasks/helpers/appimage.yml +++ b/tasks/helpers/appimage.yml @@ -1,33 +1,29 @@ # vim: set filetype=yaml.ansible : --- -- name: Install appimage {{ pkg }} +- name: Install appimages become: "{{ install_become }}" become_user: "{{ install_become_user }}" block: - name: Ensure appimage path exists ansible.builtin.file: - path: "{{ path_appimage }}/{{ pkg.name }}" - mode: "{{ pkg.mode | default('0755') }}" - owner: "{{ pkg.owner | default(ansible_user_id) }}" - group: "{{ pkg.group | default(ansible_user_gid) }}" + path: "{{ path_appimage }}/{{ appimage.name }}" + mode: "{{ appimage.mode | default('0755') }}" + owner: "{{ appimage.owner | default(ansible_user_id) }}" + group: "{{ appimage.group | default(ansible_user_gid) }}" state: directory - name: Fetch appimage - become: "{{ install_become }}" - become_user: "{{ install_become_user }}" ansible.builtin.get_url: - mode: "{{ pkg.mode | default('0755') }}" - owner: "{{ pkg.owner | default(ansible_user_id) }}" - group: "{{ pkg.group | default(ansible_user_gid) }}" - url: "{{ pkg.url }}" - dest: "{{ path_appimage }}/{{ pkg.name }}/{{ pkg.filename }}" + mode: "{{ appimage.mode | default('0755') }}" + owner: "{{ appimage.owner | default(ansible_user_id) }}" + group: "{{ appimage.group | default(ansible_user_gid) }}" + url: "{{ appimage.url }}" + dest: "{{ path_appimage }}/{{ appimage.name }}/{{ appimage.filename }}" decompress: false backup: false - name: Link appimage to bin - become: "{{ install_become }}" - become_user: "{{ install_become_user }}" ansible.builtin.file: state: link - src: "{{ path_appimage }}/{{ pkg.name }}/{{ pkg.filename }}" - path: "{{ path_bin }}/{{ pkg.name }}" + src: "{{ path_appimage }}/{{ appimage.name }}/{{ appimage.filename }}" + path: "{{ path_bin }}/{{ appimage.name }}" diff --git a/tasks/helpers/archive.yml b/tasks/helpers/archive.yml index cd45132..ef35939 100644 --- a/tasks/helpers/archive.yml +++ b/tasks/helpers/archive.yml @@ -2,9 +2,9 @@ --- - name: Ensure requirements met when: - - pkg.extract_to is defined - - pkg.name is defined - - pkg.url is defined + - archive.extract_to is defined + - archive.name is defined + - archive.url is defined block: - name: Extract archive to given path block: @@ -13,16 +13,16 @@ become_user: "{{ install_become_user }}" ansible.builtin.file: state: directory - path: "{{ pkg.extract_to }}" - mode: "{{ pkg.mode | default('0755') }}" - owner: "{{ pkg.owner | default(ansible_user_id)}}" - group: "{{ pkg.group | default(ansible_user_gid) }}" + path: "{{ archive.extract_to }}" + mode: "{{ archive.mode | default('0755') }}" + owner: "{{ archive.owner | default(ansible_user_id)}}" + group: "{{ archive.group | default(ansible_user_gid) }}" - name: Download archive to cache ansible.builtin.get_url: - dest: "{{ d_cache.path }}/{{ pkg.name }}" - url: "{{ pkg.url }}" - checksum: "{{ pkg.checksum | default(omit) }}" + dest: "{{ d_cache.path }}/{{ archive.name }}" + url: "{{ archive.url }}" + checksum: "{{ archive.checksum | default(omit) }}" decompress: false mode: '0644' @@ -30,19 +30,19 @@ become: "{{ install_become }}" become_user: "{{ install_become_user }}" ansible.builtin.unarchive: - dest: "{{ pkg.extract_to }}" - src: "{{ d_cache.path }}/{{ pkg.name }}" + dest: "{{ archive.extract_to }}" + src: "{{ d_cache.path }}/{{ archive.name }}" remote_src: true - include: "{{ pkg.include | default(omit) }}" - exclude: "{{ pkg.exclude | default(omit) }}" + include: "{{ archive.include | default(omit) }}" + exclude: "{{ archive.exclude | default(omit) }}" - name: Symlink archive files become: "{{ install_become }}" become_user: "{{ install_become_user }}" when: - - pkg.links is defined - - pkg.links | length > 0 - loop: "{{ pkg.links }}" + - archive.links is defined + - archive.links | length > 0 + loop: "{{ archive.links }}" loop_control: loop_var: lnk ansible.builtin.file: diff --git a/tasks/helpers/cargo.yml b/tasks/helpers/cargo.yml index 629e62f..4a0d11f 100644 --- a/tasks/helpers/cargo.yml +++ b/tasks/helpers/cargo.yml @@ -4,7 +4,7 @@ become: "{{ install_become }}" become_user: "{{ install_become_user }}" community.general.cargo: - name: "{{ pkg.name | default(pkg) }}" - version: "{{ pkg.version | default(omit) }}" - locked: "{{ pkg.locked | default(false) }}" + name: "{{ cargo.name }}" + version: "{{ cargo.version | default(omit) }}" + locked: "{{ cargo.locked | default(false) }}" path: "{{ install_prefix }}" diff --git a/tasks/helpers/cargo_build.yml b/tasks/helpers/cargo_build.yml index 59514d5..830ed9c 100644 --- a/tasks/helpers/cargo_build.yml +++ b/tasks/helpers/cargo_build.yml @@ -2,64 +2,50 @@ --- - name: Cargo source install helper block: - - name: Set build variables - ansible.builtin.set_fact: - git_path: "{{ d_tempdir.path }}/{{ pkg.name }}" - git_repo: "{{ pkg.repo }}" - git_depth: "{{ pkg.depth | default(1) }}" - git_recursive: "{{ pkg.recursive | default(true) }}" - git_version: "{{ pkg.version | default(omit) }}" - - 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 - name: Build cargo release ansible.builtin.command: - creates: "{{ pkg.bin_output }}" - chdir: "{{ pkg.path }}" - argv: "{{ [cargo, build] + pkg.build_flags }}" + chdir: "{{ d_cache.path }}/{{ cargo_build.name }}" + argv: "{{ [cargo, build] + cargo_build.build_flags }}" - name: Install cargo release block: - - name: Install binary - when: - - bin_name is defined - - bin_output is defined - become: true + - 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 - dest: "{{ install_prefix }}/bin/{{ bin_name }}" - owner: root - group: root - mode: "0755" remote_src: true - src: "{{ git_path }}/{{ bin_output }}" - - - name: Install additional files - when: - - install_files is defined - block: - - name: Create missing directories - loop: "{{ install_files | dict2items }}" - loop_control: - loop_var: file - ansible.builtin.file: - path: "{{ install_prefix }}/{{ file.value | dirname }}" - owner: root - group: root - mode: "0755" - state: directory - - - name: Copy extra files - loop: "{{ install_files | dict2items }}" - loop_control: - loop_var: file - ansible.builtin.copy: - backup: false - dest: "{{ install_prefix }}/{{ file.value }}" - owner: root - group: root - mode: "0644" - remote_src: true - src: "{{ git_path }}/{{ file.key }}" + 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) }}" diff --git a/tasks/helpers/flatpak.yml b/tasks/helpers/flatpak.yml index 82dfcb4..8e0d361 100644 --- a/tasks/helpers/flatpak.yml +++ b/tasks/helpers/flatpak.yml @@ -4,7 +4,7 @@ become: "{{ install_become }}" become_user: "{{ install_become_user }}" community.general.flatpak: - method: "{{ flatpak.method | default('system') }}" - remote: "{{ flatpak.remote }}" name: "{{ flatpak.name }}" + remote: "{{ flatpak.remote }}" + method: "{{ flatpak.method | default('system') }}" state: "{{ flatpak.state | default('present') }}" diff --git a/tasks/helpers/flatpak_remote.yml b/tasks/helpers/flatpak_remote.yml index a266dda..ab7f32a 100644 --- a/tasks/helpers/flatpak_remote.yml +++ b/tasks/helpers/flatpak_remote.yml @@ -4,8 +4,8 @@ become: "{{ install_become }}" become_user: "{{ install_become_user }}" community.general.flatpak_remote: - enabled: "{{ remote.enabled | default(true) }}" - flatpakrepo_url: "{{ remote.url }}" - method: "{{ remote.method | default('system') }}" name: "{{ remote.name }}" + flatpakrepo_url: "{{ remote.url }}" + enabled: "{{ remote.enabled | default(true) }}" + method: "{{ remote.method | default('system') }}" state: "{{ remote.state | default('present') }}" diff --git a/tasks/linux.yml b/tasks/linux.yml index 3e9556c..a3a512a 100644 --- a/tasks/linux.yml +++ b/tasks/linux.yml @@ -16,17 +16,11 @@ - name: Install flatpaks when: - pkg_flatpak|length > 0 - block: - - name: Install flatpak - loop: "{{ pkg_flatpak | unique }}" - loop_control: - loop_var: flatpak - 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 + loop: "{{ pkg_flatpak | unique }}" + loop_control: + loop_var: flatpak + ansible.builtin.include_tasks: + file: helpers/flatpak.yml - name: Install pkg_appimage when: @@ -34,9 +28,5 @@ loop: "{{ pkg_appimage }}" loop_control: loop_var: appimage - vars: - appimage_link_name: "{{ appimage.link_name }}" - appimage_url: "{{ appimage.url }}" - appimage_file: "{{ appimage.file }}" ansible.builtin.include_tasks: file: helpers/appimage.yml diff --git a/tasks/main.yml b/tasks/main.yml index 3467d51..0d95020 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -86,42 +86,42 @@ - name: Ensure pipx is installed when: - pkg_pipx|length > 0 - ansible.builtin.include_tasks: - file: pkgs/pipx.yml + block: + - name: Queue pipx install + ansible.builtin.include_tasks: + file: pkgs/pipx.yml -- name: Ensure pipx path exists - when: pkg_pipx|length > 0 - become: "{{ ext_become }}" - ansible.builtin.file: - state: directory - mode: '0755' - path: "{{ path.pipx }}" + - name: Ensure pipx path exists + become: "{{ install_become }}" + become_user: "{{ install_become_user }}" + ansible.builtin.file: + state: directory + mode: '0755' + path: "{{ path_pipx }}" - name: Ensure nodejs and npm are installed - when: pkg_npm|length > 0 - vars: - pkg: nodejs + when: + - pkg_npm|length > 0 ansible.builtin.include_tasks: - file: addpkg.yml + file: pkgs/nodejs.yml - name: Ensure flatpak is installed when: - pkg_flatpak is defined - pkg_flatpak|length > 0 - vars: - pkg: flatpak ansible.builtin.include_tasks: - file: addpkg.yml + file: pkgs/flatpak.yml - name: Ensure appimage path exists when: - pkg_appimage is defined - pkg_appimage|length > 0 - become: "{{ ext_become }}" + become: "{{ install_become }}" + become_user: "{{ install_become_user }}" ansible.builtin.file: state: directory mode: '0755' - path: "{{ path.appimage }}" + path: "{{ path_appimage }}" - name: Ensure archive path exists when: @@ -134,13 +134,14 @@ path: "{{ path_archive }}" - name: Depend zig - when: pkg_zig|length > 0 - vars: - pkg: zig + when: + - pkg_zig|length > 0 ansible.builtin.include_tasks: - file: addpkg.yml + file: pkgs/zig.yml -- name: Install sys_pkgs list using system package manager +- name: Install pkg_sys list using system package manager + when: + - pkg_sys|length > 0 become: "{{ install_become }}" become_user: "{{ install_become_user }}" ansible.builtin.package: @@ -152,7 +153,7 @@ - pkg_archive|length > 0 loop: "{{ pkg_archive }}" loop_control: - loop_var: pkg + loop_var: archive ansible.builtin.include_tasks: file: helpers/archive.yml @@ -173,18 +174,19 @@ - pkg_cargo|length > 0 block: - name: Ensure cargo path exists - become: "{{ ext_become }}" + become: "{{ install_become }}" + become_user: "{{ install_become_user }}" ansible.builtin.file: state: directory mode: '0755' - path: "{{ path.cargo }}" + path: "{{ path_cargo }}" - name: Install cargo packages loop: "{{ pkg_cargo | unique }}" loop_control: - loop_var: pkg + loop_var: cargo ansible.builtin.include_tasks: - file: cargo.yml + file: helpers/cargo.yml - name: Build and install rust apps when: @@ -193,16 +195,7 @@ - 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) }}" + loop_var: cargo_build ansible.builtin.include_tasks: file: helpers/cargo_build.yml diff --git a/tasks/pkgs/alacritty.yml b/tasks/pkgs/alacritty.yml index f6d4a37..dda3f48 100644 --- a/tasks/pkgs/alacritty.yml +++ b/tasks/pkgs/alacritty.yml @@ -2,7 +2,7 @@ --- - name: Configure alacritty # {{{ when: - - __alacritty_configured is undefined + - "'alacritty' not in __configured" block: - name: Set alacritty install method when: @@ -16,41 +16,41 @@ ansible.builtin.set_fact: alacritty_build_deps: "{{ alacritty_build_deps[ansible_os_family] }}" alacritty_src_install: - cargo_build_flags: "{{ alacritty_cargo_build_flags }}" + build_flags: "{{ alacritty_cargo_build_flags }}" name: "{{ alacritty_pkgname }}" repo: "{{ alacritty_git_repo }}" version: "{{ alacritty_version }}" - bin_output: "target/release/alacritty" - bin_name: "alacritty" - install_prefix: "{{ install_prefix }}" - install_files: - extra/logo/alacritty-term.svg: share/pixmaps/Alacritty.svg - desktop_files: - - extra/linux/Alacritty.desktop - files_list: "{{ alacritty_build_files }}" + 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 - - name: Set alacritty install extra build deps + - name: Set alacritty install extra build deps + when: + - alacritty_install_method == "source" + - ansible_os_family == "RedHat" + - ansible_os_major_version < 9 + block: + - name: Add extra dependencies for EL7 when: - - alacritty_install_method == "source" - - ansible_os_family == "RedHat" - - ansible_os_major_version < 9 - block: - - name: Add extra dependencies for EL7 - when: - - ansible_distribution_major_version == 7 - ansible.builtin.set_fact: - alacritty_build_deps: "{{ alacritty_build_deps + ['xcb-util-devel', '@Development Tools'] }}" + - ansible_distribution_major_version == 7 + ansible.builtin.set_fact: + alacritty_build_deps: "{{ alacritty_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'] }}" + - name: Add extra dependencies for EL8 + when: + - ansible_distribution_major_version == 8 + ansible.builtin.set_fact: + alacritty_build_deps: "{{ alacritty_build_deps + ['@Development Tools'] }}" # }}} - name: Append alacritty installation block: - - name: Append alacritty to pkg_cargo + - name: Append alacritty to pkg_cargo_build when: - alacritty_method == 'source' block: @@ -64,19 +64,13 @@ pkg_sys: "{{ pkg_sys + alacritty_build_deps }}" pkg_cargo_build: "{{ pkg_cargo_build + [alacritty_src_install] }}" - - name: Append alacritty to pkg_cask + - name: Append alacritty to pkg_sys when: - - alacritty_method == 'cask' - ansible.builtin.set_fact: - pkg_cask: "{{ pkg_cask + [alacritty_pkgname] }}" - - - name: Append alacritty to sys_pkg - when: - - alacritty_method == 'package' + - alacritty_method == 'system' ansible.builtin.set_fact: pkg_sys: "{{ pkg_sys + [alacritty_pkgname] }}" - name: Complete alacritty configuration when: __alacritty_configured is undefined ansible.builtin.set_fact: - __alacritty_configured: true + __configured: "{{ __configured | combine( { 'alacritty': true } ) }}"