2016-11-07 14:00:57 +01:00
|
|
|
---
|
|
|
|
|
2017-07-28 03:33:34 +02:00
|
|
|
- name: Git is installed (Debian)
|
2016-11-07 14:00:57 +01:00
|
|
|
apt:
|
|
|
|
name: git
|
|
|
|
state: present
|
2018-03-16 14:20:25 +01:00
|
|
|
tags:
|
|
|
|
- etc-git
|
2016-11-07 14:00:57 +01:00
|
|
|
|
2021-10-12 18:23:50 +02:00
|
|
|
- include_role:
|
|
|
|
name: evolix/remount-usr
|
|
|
|
|
|
|
|
- name: "evocommit script is installed"
|
|
|
|
copy:
|
|
|
|
src: evocommit
|
|
|
|
dest: /usr/local/bin/evocommit
|
|
|
|
mode: "0755"
|
|
|
|
force: yes
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
2019-11-05 17:00:22 +01:00
|
|
|
- include: repository.yml
|
|
|
|
vars:
|
|
|
|
repository_path: "/etc"
|
|
|
|
gitignore_items:
|
|
|
|
- "aliases.db"
|
|
|
|
- "*.swp"
|
|
|
|
- "postfix/sa-blacklist.access"
|
|
|
|
- "postfix/*.db"
|
|
|
|
- "postfix/spamd.cidr"
|
|
|
|
- "evobackup/.keep-*"
|
|
|
|
- "letsencrypt/.certbot.lock"
|
2016-11-07 14:00:57 +01:00
|
|
|
|
2019-11-05 17:00:22 +01:00
|
|
|
- name: verify /usr/share/scripts presence
|
|
|
|
stat:
|
|
|
|
path: /usr/share/scripts
|
|
|
|
register: _usr_share_scripts
|
2016-11-07 14:00:57 +01:00
|
|
|
|
2019-11-05 17:00:22 +01:00
|
|
|
- include: repository.yml
|
|
|
|
vars:
|
|
|
|
repository_path: "/usr/share/scripts"
|
|
|
|
gitignore_items: []
|
|
|
|
when:
|
|
|
|
- _usr_share_scripts.stat.isdir
|
2020-02-25 10:45:35 +01:00
|
|
|
- ansible_distribution_major_version is version('10', '>=')
|
2018-08-24 00:28:15 +02:00
|
|
|
|
2021-10-02 12:50:01 +02:00
|
|
|
- name: "etc-git-optimize script is installed"
|
|
|
|
copy:
|
|
|
|
src: etc-git-optimize
|
|
|
|
dest: /usr/share/scripts/etc-git-optimize
|
|
|
|
mode: "0755"
|
|
|
|
force: yes
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: "etc-git-status script is installed"
|
|
|
|
copy:
|
|
|
|
src: etc-git-status
|
|
|
|
dest: /usr/share/scripts/etc-git-status
|
|
|
|
mode: "0755"
|
|
|
|
force: yes
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
2019-10-21 15:25:00 +02:00
|
|
|
- name: Check if cron is installed
|
2021-06-28 15:39:04 +02:00
|
|
|
shell: "set -o pipefail && dpkg -l cron 2>/dev/null | grep -q -E '^(i|h)i'"
|
2021-05-18 14:04:54 +02:00
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
2019-10-21 15:25:00 +02:00
|
|
|
failed_when: False
|
|
|
|
changed_when: False
|
|
|
|
check_mode: no
|
|
|
|
register: is_cron_installed
|
|
|
|
|
2021-10-02 12:50:01 +02:00
|
|
|
- block:
|
|
|
|
- name: Legacy cron jobs for /etc/.git status are absent
|
|
|
|
file:
|
|
|
|
dest: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- /etc/cron.monthly/optimize-etc-git
|
|
|
|
- /etc/cron.d/etc-git-status
|
2018-09-07 21:49:30 +02:00
|
|
|
|
2021-10-02 12:50:01 +02:00
|
|
|
- name: Cron job for monthly git optimization
|
|
|
|
cron:
|
|
|
|
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
|
|
|
|
cron:
|
|
|
|
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') }}"
|
2018-09-08 01:05:58 +02:00
|
|
|
|
2021-10-02 12:50:01 +02:00
|
|
|
- name: Cron job for daily git status
|
|
|
|
cron:
|
|
|
|
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
|
2018-09-07 21:49:30 +02:00
|
|
|
tags:
|
2021-10-02 12:50:01 +02:00
|
|
|
- etc-git
|