ansible-roles/etc-git/tasks/main.yml

109 lines
2 KiB
YAML
Raw Normal View History

---
2017-07-28 03:33:34 +02:00
- name: Git is installed (Debian)
apt:
name: git
state: present
2018-03-16 14:20:25 +01:00
tags:
- etc-git
- name: /etc is versioned with git
command: "git init ."
args:
chdir: /etc
creates: /etc/.git/
2017-05-19 22:30:51 +02:00
warn: no
register: git_init
2018-03-16 14:20:25 +01:00
tags:
- etc-git
- name: Git user.email is configured
git_config:
name: user.email
repo: /etc
scope: local
value: "root@{{ ansible_fqdn | default('localhost') }}"
2018-03-16 14:20:25 +01:00
tags:
- etc-git
- name: /etc/.git is restricted to root
2016-12-26 12:10:13 +01:00
file:
path: /etc/.git
owner: root
mode: "0700"
2016-12-26 12:10:13 +01:00
state: directory
2018-03-16 14:20:25 +01:00
tags:
- etc-git
2016-12-26 12:10:13 +01:00
- name: /etc/.gitignore is present
copy:
src: gitignore
dest: /etc/.gitignore
owner: root
mode: "0600"
force: no
tags:
- etc-git
- name: Some entries MUST be in the /etc/.gitignore file
lineinfile:
dest: /etc/.gitignore
line: "{{ item }}"
with_items:
- "aliases.db"
- "*.swp"
- "postfix/sa-blacklist.access"
- "postfix/*.db"
- "postfix/spamd.cidr"
- "evobackup/.keep-*"
2018-03-16 14:20:25 +01:00
tags:
- etc-git
- name: does /etc/ have any commit?
command: "git log"
args:
chdir: /etc
2017-05-19 22:30:51 +02:00
warn: no
changed_when: False
failed_when: False
register: git_log
2017-03-24 14:15:09 +01:00
check_mode: no
2018-03-16 14:20:25 +01:00
tags:
- etc-git
- name: initial commit is present?
shell: "git add -A . && git commit -m \"Initial commit via Ansible\""
args:
chdir: /etc
2017-05-19 22:30:51 +02:00
warn: no
register: git_commit
when: git_log.rc != 0 or (git_init is defined and git_init.changed)
2018-03-16 14:20:25 +01:00
tags:
- etc-git
- name: Optimize script is installed in monthly crontab
copy:
src: optimize-etc-git
dest: /etc/cron.monthly/optimize-etc-git
mode: "0750"
force: no
tags:
- etc-git
2018-09-08 01:05:58 +02:00
- name: Cron job for /etc/.git status is installed
template:
src: etc-git-status.j2
dest: /etc/cron.d/etc-git-status
mode: "0644"
2018-09-08 01:05:58 +02:00
when: etc_git_monitor_status
tags:
- etc-git
- name: Cron job for /etc/.git status is removed
file:
dest: /etc/cron.d/etc-git-status
state: absent
when: not etc_git_monitor_status
tags:
- etc-git