44 lines
894 B
YAML
44 lines
894 B
YAML
---
|
|
- name: Install etckeeper (Archlinux)
|
|
become: true
|
|
pacman:
|
|
name:
|
|
- etckeeper
|
|
when: ansible_facts['distribution'] == 'Archlinux'
|
|
|
|
- name: Install etckeeper (Debian)
|
|
become: true
|
|
apt:
|
|
name:
|
|
- etckeeper
|
|
when: ansible_facts['distribution'] == 'Debian'
|
|
|
|
- name: Copy gitconfig for root
|
|
become: true
|
|
template:
|
|
src: gitconfig.j2
|
|
dest: /root/.gitconfig
|
|
backup: true
|
|
|
|
- name: Check if etckeeper is initialized
|
|
stat:
|
|
path: /etc/.git
|
|
register: etckeeper_git
|
|
|
|
- name: Initialize etckeeper
|
|
become: true
|
|
command: etckeeper init
|
|
when: not etckeeper_git.stat.exists
|
|
|
|
- name: Check if first commit exists
|
|
become: true
|
|
command:
|
|
cmd: git status
|
|
chdir: /etc
|
|
register: git_status
|
|
changed_when: false
|
|
|
|
- name: Make first commit
|
|
become: true
|
|
command: etckeeper commit 'First commit'
|
|
when: "'No commits yet' in git_status.stdout"
|