From f9cc864d0482b8077179b346bfe9ad83a2327deb Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 11 Sep 2023 12:50:37 +0200 Subject: etckeeper: commit etckeeper.conf changes --- roles/etckeeper/handlers/commit_conf.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 roles/etckeeper/handlers/commit_conf.yml (limited to 'roles/etckeeper/handlers/commit_conf.yml') diff --git a/roles/etckeeper/handlers/commit_conf.yml b/roles/etckeeper/handlers/commit_conf.yml new file mode 100644 index 0000000..a9eb409 --- /dev/null +++ b/roles/etckeeper/handlers/commit_conf.yml @@ -0,0 +1,24 @@ +- name: Get list of modified files + become: true + ansible.builtin.shell: | + set -o pipefail && \ + git status --porcelain=v1 \ + | cut -c 4- \ + | grep -G -v '^etckeeper/etckeeper.conf' + args: + chdir: /etc + register: etckeeper_modified_files + changed_when: false + failed_when: etckeeper_modified_files.rc not in [0, 1] + +- name: Fail if unexpected files were modified + ansible.builtin.fail: + msg: | + Unexpected files were modified: + {{ etckeeper_modified_files.stdout }} + when: etckeeper_modified_files.rc == 0 + +- name: etckeeper commit + become: true + ansible.builtin.command: | + etckeeper commit 'configure etckeeper' -- cgit v1.2.3