aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/roles/etckeeper/handlers/commit.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/etckeeper/handlers/commit.yml')
-rw-r--r--roles/etckeeper/handlers/commit.yml24
1 files changed, 24 insertions, 0 deletions
diff --git a/roles/etckeeper/handlers/commit.yml b/roles/etckeeper/handlers/commit.yml
new file mode 100644
index 0000000..f48db8f
--- /dev/null
+++ b/roles/etckeeper/handlers/commit.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 '^{{ paths | map("regex_replace", "^/", "") | list | join("\|^") }}'
+ args:
+ chdir: /etc
+ register: git_status
+ changed_when: false
+ failed_when: git_status.rc not in [0, 1]
+
+- name: Fail if unexpected files were modified
+ ansible.builtin.fail:
+ msg: |
+ Unexpected files were modified:
+ {{ git_status.stdout }}
+ when: git_status.rc == 0
+
+- name: etckeeper commit
+ become: true
+ ansible.builtin.command: |
+ etckeeper commit '{{ commit_msg }}'