From 01239701f99733555d5aa18468f50b1eab7fbde9 Mon Sep 17 00:00:00 2001 From: Matthew Stobbs Date: Sat, 18 Apr 2026 18:44:18 -0600 Subject: [PATCH] add restic - fix packages that were broken - change the way configuration is done - define default facts for packages with os_family level vars - refine the default facts into an os_family specfic config --- tasks/helpers/go_install.yml | 16 ++++++++++++++ tasks/helpers/npm.yml | 3 --- tasks/main.yml | 4 ---- tasks/pkgs/cheat.yml | 8 +++++++ tasks/pkgs/go.yml | 1 + tasks/pkgs/restic.yml | 43 ++++++++++++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 7 deletions(-) diff --git a/tasks/helpers/go_install.yml b/tasks/helpers/go_install.yml index 7a00db4..9e585e0 100644 --- a/tasks/helpers/go_install.yml +++ b/tasks/helpers/go_install.yml @@ -5,9 +5,25 @@ files: "{{ pkg.files | default([]) }}" ansible.builtin.include_tasks: helpers/clean_install.yml +- name: Install go package using system go + become: "{{ install_become }}" + become_user: "{{ install_become_user }}" + when: + - go_imethod == 'system' + environment: + GOBIN: "{{ path_bin }}" + ansible.builtin.command: + creates: "{{ pkg.bin }}" + argv: + - go + - install + - "{{ pkg.url }}" + - name: Install go package "{{ pkg.url }}" become: "{{ install_become }}" become_user: "{{ install_become_user }}" + when: + - go_imethod != 'system' environment: GOBIN: "{{ path_bin }}" GOROOT: "{{ path_go }}" diff --git a/tasks/helpers/npm.yml b/tasks/helpers/npm.yml index 6864921..ff42439 100644 --- a/tasks/helpers/npm.yml +++ b/tasks/helpers/npm.yml @@ -1,8 +1,5 @@ # vim: set filetype=yaml.ansible : --- -- name: Dump npm pkg - ansible.builtin.debug: - var: pkg - name: Install npm become: "{{ install_become }}" become_user: "{{ install_become_user }}" diff --git a/tasks/main.yml b/tasks/main.yml index c937f69..9f95e1b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -66,10 +66,6 @@ ansible.builtin.include_tasks: file: "pkgs/{{ pkg }}.yml" -- name: Dump pkg_sys - debug: - var: pkg_sys - - name: Install pkg_sys list using system package manager when: - pkg_sys|length > 0 diff --git a/tasks/pkgs/cheat.yml b/tasks/pkgs/cheat.yml index 547ef63..7ff46ee 100644 --- a/tasks/pkgs/cheat.yml +++ b/tasks/pkgs/cheat.yml @@ -13,6 +13,8 @@ - source go_pkg: github.com/cheat/cheat/cmd/cheat version: latest + pkg_deps: + - go # }}} - name: Configure cheat when: @@ -28,6 +30,12 @@ when: - cheat_imethod == 'source' block: + - name: Queue package dependencies + loop: "{{ cheat.pkg_deps }}" + loop_control: + loop_var: dep + ansible.builtin.include_tasks: pkgs/{{ dep }}.yml + - name: Configure cheat go install ansible.builtin.set_fact: cheat_go_install: diff --git a/tasks/pkgs/go.yml b/tasks/pkgs/go.yml index 7916712..8992d9b 100644 --- a/tasks/pkgs/go.yml +++ b/tasks/pkgs/go.yml @@ -78,6 +78,7 @@ - name: Go system package install ansible.builtin.set_fact: pkg_sys: "{{ pkg_sys + [go_pkgname] }}" + go_install: "{{ go_imethod }}={{ go_pkgname }}" - name: Configure go archive installation when: diff --git a/tasks/pkgs/restic.yml b/tasks/pkgs/restic.yml index e69de29..79cba34 100644 --- a/tasks/pkgs/restic.yml +++ b/tasks/pkgs/restic.yml @@ -0,0 +1,43 @@ +# vim: set filetype=yaml.ansible : +# +## Package: restic +## Description: backup with builtin encryption and compression +## Version: system +## Methods: system +## Helpers: - +--- +- name: Set restic default facts # {{{ + ansible.builtin.set_fact: + restic: + methods: + default: [system] + pkgname: + default: restic +- name: Finalise restic default facts + ansible.builtin.set_fact: + restic: + methods: "{{ restic.methods[os_family] | default(restic.methods.default) }}" + pkgname: "{{ restic.pkgname[os_family] | default(restic.pkgname.default) }}" +# }}} +- name: Configure restic + when: + - "'restic' not in __configured" + block: + - name: Set restic install method + when: + - restic_imethod is undefined + ansible.builtin.set_fact: + restic_imethod: "{{ imethod if imethod in restic.methods else restic.methods[0] }}" + + - name: Configure restic system install + when: + - restic_imethod == 'system' + block: + - name: Queue restic system install + ansible.builtin.set_fact: + pkg_sys: "{{ pkg_sys + [restic.pkgname] }}" + restic_install: "{{ restic_imethod }}={{ restic.pkgname }}" + + - name: Finalise restic configuration + ansible.builtin.set_fact: + __configured: "{{ __configured | combine( { 'restic': restic_install } ) }}"