2018-12-28 11:23:49 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Git is installed
|
|
|
|
openbsd_pkg:
|
|
|
|
name: git
|
|
|
|
state: present
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: /etc is versioned with git
|
|
|
|
command: "git init ."
|
|
|
|
args:
|
|
|
|
chdir: /etc
|
|
|
|
creates: /etc/.git/
|
2020-06-01 11:37:15 +02:00
|
|
|
warn: false
|
2018-12-28 11:23:49 +01:00
|
|
|
register: git_init
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: Git user.email is configured
|
|
|
|
git_config:
|
|
|
|
name: user.email
|
|
|
|
repo: /etc
|
|
|
|
scope: local
|
2020-10-14 16:33:39 +02:00
|
|
|
value: "root@{{ inventory_hostname }}.{{ general_technical_realm }}"
|
2018-12-28 11:23:49 +01:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: /etc/.git is secure
|
|
|
|
file:
|
|
|
|
path: /etc/.git
|
|
|
|
owner: root
|
|
|
|
mode: "0700"
|
|
|
|
state: directory
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: /etc/.gitignore is present
|
|
|
|
copy:
|
|
|
|
src: gitignore
|
|
|
|
dest: /etc/.gitignore
|
|
|
|
owner: root
|
|
|
|
mode: "0600"
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: does /etc/ have any commit?
|
|
|
|
command: "git log"
|
|
|
|
args:
|
|
|
|
chdir: /etc
|
2020-06-01 11:37:15 +02:00
|
|
|
warn: false
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
2018-12-28 11:23:49 +01:00
|
|
|
register: git_log
|
2020-06-01 11:37:15 +02:00
|
|
|
check_mode: false
|
2018-12-28 11:23:49 +01:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: initial commit is present?
|
|
|
|
shell: "git add -A . && git commit -m \"Initial commit via Ansible\""
|
|
|
|
args:
|
|
|
|
chdir: /etc
|
2020-06-01 11:37:15 +02:00
|
|
|
warn: false
|
2018-12-28 11:23:49 +01:00
|
|
|
register: git_commit
|
|
|
|
when: git_log.rc != 0 or (git_init is defined and git_init.changed)
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: Optimize script is installed in monthly crontab
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/monthly.local
|
|
|
|
line: '/usr/local/bin/git --git-dir /etc/.git gc --quiet'
|
|
|
|
owner: root
|
2019-01-18 15:12:40 +01:00
|
|
|
mode: "0644"
|
2020-06-01 11:37:15 +02:00
|
|
|
create: true
|
2018-12-28 11:23:49 +01:00
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: cron job for /etc/.git status is installed
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/daily.local
|
2020-10-12 14:20:59 +02:00
|
|
|
line:
|
|
|
|
'/usr/local/bin/git --git-dir=/etc/.git --work-tree=/etc status --short'
|
2018-12-28 11:23:49 +01:00
|
|
|
owner: root
|
2019-01-18 15:12:40 +01:00
|
|
|
mode: "0644"
|
2020-06-01 11:37:15 +02:00
|
|
|
create: true
|
2018-12-28 11:23:49 +01:00
|
|
|
when: etc_git_monitor_status
|
|
|
|
tags:
|
|
|
|
- etc-git
|
2020-10-12 12:00:28 +02:00
|
|
|
|
|
|
|
- name: cron job for /etc/.git status is installed - next_part
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/daily.local
|
|
|
|
line: 'next_part "Checking /etc git status:"'
|
2020-10-12 14:20:59 +02:00
|
|
|
insertbefore:
|
|
|
|
'/usr/local/bin/git --git-dir=/etc/.git --work-tree=/etc status --short'
|
2020-10-21 10:52:39 +02:00
|
|
|
owner: root
|
|
|
|
mode: "0644"
|
|
|
|
create: true
|
2020-10-12 12:00:28 +02:00
|
|
|
when: etc_git_monitor_status
|
|
|
|
tags:
|
|
|
|
- etc-git
|
2018-12-28 11:23:49 +01:00
|
|
|
|
|
|
|
- name: cron job for /etc/.git status is removed
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/daily.local
|
2020-10-12 12:00:28 +02:00
|
|
|
line: "{{ item }}"
|
2018-12-28 11:23:49 +01:00
|
|
|
owner: root
|
2019-01-18 15:12:40 +01:00
|
|
|
mode: "0644"
|
2018-12-28 11:23:49 +01:00
|
|
|
state: absent
|
2020-10-12 12:00:28 +02:00
|
|
|
with_items:
|
|
|
|
- 'next_part "Checking /etc git status:"'
|
|
|
|
- '/usr/local/bin/git --git-dir=/etc/.git --work-tree=/etc status --short'
|
2018-12-28 11:23:49 +01:00
|
|
|
when: not etc_git_monitor_status
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: hourly cron job for /etc/.git status is installed
|
|
|
|
cron:
|
|
|
|
name: git status
|
|
|
|
minute: 42
|
2020-06-04 18:51:53 +02:00
|
|
|
job: >
|
|
|
|
who
|
|
|
|
> /dev/null
|
2020-07-02 16:40:17 +02:00
|
|
|
|| /usr/local/bin/git
|
|
|
|
--git-dir=/etc/.git
|
|
|
|
--work-tree=/etc
|
|
|
|
status --short
|
2018-12-28 11:23:49 +01:00
|
|
|
when: etc_git_monitor_status
|
|
|
|
tags:
|
|
|
|
- etc-git
|
|
|
|
|
|
|
|
- name: hourly cron job for /etc/.git status is removed
|
|
|
|
cron:
|
|
|
|
name: git status
|
|
|
|
minute: 42
|
2020-06-04 18:51:53 +02:00
|
|
|
job: >
|
|
|
|
who
|
|
|
|
> /dev/null
|
2020-07-02 16:40:17 +02:00
|
|
|
|| /usr/local/bin/git
|
|
|
|
--git-dir=/etc/.git
|
|
|
|
--work-tree=/etc
|
|
|
|
status --short
|
2018-12-28 11:23:49 +01:00
|
|
|
state: absent
|
|
|
|
when: not etc_git_monitor_status
|
|
|
|
tags:
|
|
|
|
- etc-git
|