From ed1cba3955bf4e713c8ac236d1f1b811b3c8abb25753cf14ca8be032fe9ab953 Mon Sep 17 00:00:00 2001 From: bryan Date: Sun, 14 Dec 2025 16:18:23 -0500 Subject: [PATCH] Allow per-group software --- galaxy-requirements.yml | 3 ++- group_vars/all/software.yml | 5 +++-- inventories/hosts.ini | 6 +++--- roles/software/tasks/main.yml | 25 +++++++++++++++---------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/galaxy-requirements.yml b/galaxy-requirements.yml index 96a1ac6..7601839 100644 --- a/galaxy-requirements.yml +++ b/galaxy-requirements.yml @@ -3,4 +3,5 @@ # - linux-system-roles.systemd collections: - - name: ansible.posix \ No newline at end of file + - name: ansible.posix + - name: community.general diff --git a/group_vars/all/software.yml b/group_vars/all/software.yml index 1df1c34..485a865 100644 --- a/group_vars/all/software.yml +++ b/group_vars/all/software.yml @@ -1,5 +1,5 @@ --- -dnf_add_repositories: +dnf_add_repos: - name: zsh-completions description: zsh-completions from openSUSE baseurl: https://download.opensuse.org/repositories/shells:zsh-users:zsh-completions/Fedora_Rawhide/ @@ -46,13 +46,14 @@ dnf_install: - snapd - tailscale - dnf5-plugin-automatic + - btrfs-assistant # Cargo packages to install cargo_packages: - aichat # Git repositories to clone -git_repos: +git_add_repos: - repo: https://git.bryanroessler.com/bryan/installJRMC.git dest: "{{ ansible_facts['env']['HOME'] }}/.local/bin/installJRMC" version: dev diff --git a/inventories/hosts.ini b/inventories/hosts.ini index 7130e17..0760962 100644 --- a/inventories/hosts.ini +++ b/inventories/hosts.ini @@ -16,6 +16,6 @@ bryanroessler.com ansible_host=bryanroessler.com ansible_user=bryan [testing] testing-remote ansible_host=192.168.122.205 ansible_user=bryan -[desktops:children] -workstation -laptop \ No newline at end of file +# [desktops:children] +# workstation +# laptop \ No newline at end of file diff --git a/roles/software/tasks/main.yml b/roles/software/tasks/main.yml index 817497e..bcf575a 100644 --- a/roles/software/tasks/main.yml +++ b/roles/software/tasks/main.yml @@ -1,5 +1,12 @@ --- +- name: Enable COPR repositories + community.general.copr: + name: "{{ item.repo | default(item) }}" + state: enabled + loop: "{{ (dnf_add_copr | default([])) + (dnf_add_copr_group | default([])) }}" + become: true + - name: Add DNF repositories ansible.builtin.yum_repository: name: "{{ item.name }}" @@ -8,30 +15,29 @@ enabled: true gpgcheck: true gpgkey: "{{ item.gpgkey }}" - loop: "{{ dnf_add_repositories }}" + loop: "{{ (dnf_add_repos | default([])) + (dnf_add_repos_group | default([])) }}" become: true - when: dnf_add_repositories is defined and dnf_add_repositories | length > 0 - name: Remove unwanted packages ansible.builtin.dnf: - name: "{{ dnf_remove }}" + name: "{{ (dnf_remove | default([])) + (dnf_remove_group | default([])) }}" state: absent become: true - when: dnf_remove is defined and dnf_remove | length > 0 + when: ((dnf_remove | default([])) + (dnf_remove_group | default([]))) | length > 0 failed_when: false - name: Install DNF packages ansible.builtin.dnf: - name: "{{ dnf_install }}" + name: "{{ (dnf_install | default([])) + (dnf_install_group | default([])) }}" state: present become: true - when: dnf_install is defined and dnf_install | length > 0 + when: ((dnf_install | default([])) + (dnf_install_group | default([]))) | length > 0 - name: Install cargo packages ansible.builtin.command: cmd: "cargo install {{ item }}" - loop: "{{ cargo_packages }}" - when: cargo_packages is defined and cargo_packages | length > 0 + loop: "{{ (cargo_packages | default([])) + (cargo_packages_group | default([])) }}" + when: ((cargo_packages | default([])) + (cargo_packages_group | default([]))) | length > 0 register: software_cargo_install_result changed_when: "'Installing' in software_cargo_install_result.stderr or 'Compiling' in software_cargo_install_result.stderr" failed_when: software_cargo_install_result.rc != 0 and 'already exists' not in software_cargo_install_result.stderr @@ -42,5 +48,4 @@ dest: "{{ item.dest }}" version: "{{ item.version }}" update: true - loop: "{{ git_repos }}" - when: git_repos is defined and git_repos | length > 0 + loop: "{{ (git_add_repos | default([])) + (git_add_repos_group | default([])) }}"