From d75b40d57705551e618bb280b6b27149f695aed9 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 11 Sep 2023 14:29:25 +0200 Subject: pacman: drop dependency on etckeeper role + refactoring --- roles/pacman/meta/main.yml | 2 -- roles/pacman/tasks/main.yml | 13 ++++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 roles/pacman/meta/main.yml (limited to 'roles/pacman') diff --git a/roles/pacman/meta/main.yml b/roles/pacman/meta/main.yml deleted file mode 100644 index cc61eb8..0000000 --- a/roles/pacman/meta/main.yml +++ /dev/null @@ -1,2 +0,0 @@ -dependencies: - - role: etckeeper diff --git a/roles/pacman/tasks/main.yml b/roles/pacman/tasks/main.yml index df7fac7..213ef01 100644 --- a/roles/pacman/tasks/main.yml +++ b/roles/pacman/tasks/main.yml @@ -11,6 +11,12 @@ - name: Reboot if necessary ansible.builtin.meta: flush_handlers rescue: + - name: Check if /etc is versioned + ansible.builtin.file: + path: /etc/.git/config + state: file + register: etc_versioned + - name: Fail if /etc is not versioned ansible.builtin.fail: msg: Upgrading packages failed for an unknown reason! @@ -23,7 +29,7 @@ register: git_status changed_when: false - - name: Fail if there're no unstaged changes in /etc + - name: Fail if there're no uncommitted changes in /etc ansible.builtin.fail: msg: Upgrading packages failed for an unknown reason! when: not git_status.stdout @@ -38,11 +44,12 @@ chdir: /etc register: only_gnupg changed_when: false + failed_when: only_gnupg.rc not in [0, 1] - - name: Commit changes in /etc + - name: Commit changes in /etc/pacman.d/gnupg ansible.builtin.command: | etckeeper commit 'pacman: GPG keys' - when: git_status.stdout and only_gnupg.rc != 0 + when: only_gnupg.rc == 1 - name: Retry upgrading packages community.general.pacman: -- cgit v1.2.3