2022-04-27 14:22:59 +02:00
|
|
|
---
|
|
|
|
|
2023-03-20 23:33:19 +01:00
|
|
|
- ansible.builtin.include_role:
|
2022-04-27 14:22:59 +02:00
|
|
|
name: evolix/remount-usr
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "evocommit script is installed"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.copy:
|
2022-04-27 14:22:59 +02:00
|
|
|
src: evocommit
|
|
|
|
dest: /usr/local/bin/evocommit
|
|
|
|
mode: "0755"
|
2023-06-28 13:22:59 +02:00
|
|
|
force: true
|
2022-04-27 14:22:59 +02:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "ansible-commit script is installed"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.copy:
|
2022-04-27 14:22:59 +02:00
|
|
|
src: ansible-commit
|
|
|
|
dest: /usr/local/bin/ansible-commit
|
|
|
|
mode: "0755"
|
2023-06-28 13:22:59 +02:00
|
|
|
force: true
|
2022-04-27 14:22:59 +02:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "etc-git-optimize script is installed"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.copy:
|
2022-04-27 14:22:59 +02:00
|
|
|
src: etc-git-optimize
|
|
|
|
dest: /usr/share/scripts/etc-git-optimize
|
|
|
|
mode: "0755"
|
2023-06-28 13:22:59 +02:00
|
|
|
force: true
|
2022-04-27 14:22:59 +02:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "etc-git-status script is installed"
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.copy:
|
2022-04-27 14:22:59 +02:00
|
|
|
src: etc-git-status
|
|
|
|
dest: /usr/share/scripts/etc-git-status
|
|
|
|
mode: "0755"
|
2023-06-28 13:22:59 +02:00
|
|
|
force: true
|
2022-04-27 14:22:59 +02:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: Check if cron is installed
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "set -o pipefail && dpkg -l cron 2>/dev/null | grep -q -E '^(i|h)i'"
|
2022-04-27 14:22:59 +02:00
|
|
|
executable: /bin/bash
|
|
|
|
failed_when: False
|
|
|
|
changed_when: False
|
|
|
|
check_mode: no
|
|
|
|
register: is_cron_installed
|
|
|
|
|
|
|
|
- block:
|
2023-01-06 09:54:51 +01:00
|
|
|
- name: Legacy cron jobs for /etc/.git status are absent
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.file:
|
2022-04-27 14:22:59 +02:00
|
|
|
dest: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- /etc/cron.monthly/optimize-etc-git
|
|
|
|
- /etc/cron.d/etc-git-status
|
|
|
|
|
|
|
|
- name: Cron job for monthly git optimization
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.cron:
|
2022-04-27 14:22:59 +02:00
|
|
|
name: "Monthly optimization"
|
|
|
|
cron_file: etc-git
|
|
|
|
special_time: "monthly"
|
|
|
|
user: root
|
|
|
|
job: "/usr/share/scripts/etc-git-optimize"
|
|
|
|
|
|
|
|
- name: Cron job for hourly git status
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.cron:
|
2022-04-27 14:22:59 +02:00
|
|
|
name: "Hourly warning for unclean Git repository if nobody is connected"
|
|
|
|
cron_file: etc-git
|
|
|
|
special_time: "hourly"
|
|
|
|
user: root
|
|
|
|
job: "who > /dev/null || /usr/share/scripts/etc-git-status"
|
|
|
|
state: "{{ etc_git_monitor_status | bool | ternary('present','absent') }}"
|
|
|
|
|
|
|
|
- name: Cron job for daily git status
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.cron:
|
2022-04-27 14:22:59 +02:00
|
|
|
name: "Daily warning for unclean Git repository"
|
|
|
|
cron_file: etc-git
|
|
|
|
user: root
|
|
|
|
job: "/usr/share/scripts/etc-git-status"
|
|
|
|
minute: "21"
|
|
|
|
hour: "21"
|
|
|
|
weekday: "*"
|
|
|
|
day: "*"
|
|
|
|
month: "*"
|
|
|
|
state: "{{ etc_git_monitor_status | bool | ternary('present','absent') }}"
|
|
|
|
when: is_cron_installed.rc == 0
|
|
|
|
tags:
|
|
|
|
- etc-git
|