From 3b7ba8532f31d221c0708e2d6733bccdd3935f91 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 11 Sep 2023 18:01:37 +0200 Subject: etckeeper: manage the ignore list --- roles/etckeeper/tasks/ignore.yml | 18 ++++++++++++++++++ roles/etckeeper/tasks/main.yml | 12 ++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 roles/etckeeper/tasks/ignore.yml (limited to 'roles/etckeeper/tasks') diff --git a/roles/etckeeper/tasks/ignore.yml b/roles/etckeeper/tasks/ignore.yml new file mode 100644 index 0000000..a798368 --- /dev/null +++ b/roles/etckeeper/tasks/ignore.yml @@ -0,0 +1,18 @@ +- name: Add line to .gitignore + become: true + ansible.builtin.lineinfile: + path: /etc/.gitignore + line: '{{ ignore_path }}' + state: present + owner: root + group: root + mode: '644' + register: gitignore + notify: etckeeper_commit_gitignore + +- name: Remove path from cache + when: gitignore.changed + become: true + ansible.builtin.command: # noqa: command-instead-of-module + cmd: git rm -r --ignore-unmatch --cached -- '{{ ignore_path | regex_replace("^/", "") }}' + chdir: /etc diff --git a/roles/etckeeper/tasks/main.yml b/roles/etckeeper/tasks/main.yml index 431a378..f609ce7 100644 --- a/roles/etckeeper/tasks/main.yml +++ b/roles/etckeeper/tasks/main.yml @@ -74,3 +74,15 @@ option: PUSH_REMOTE value: '{{ etckeeper_remote_name }}' notify: etckeeper_commit_conf + +- name: Commit etckeeper.conf if necessary + ansible.builtin.meta: flush_handlers + +- name: Configure ignored paths + ansible.builtin.include_tasks: ignore.yml + loop: '{{ etckeeper_ignored_paths + etckeeper_extra_ignored_paths }}' + loop_control: + loop_var: ignore_path + +- name: Commit .gitignore if necessary + ansible.builtin.meta: flush_handlers -- cgit v1.2.3