Add role etckeeper
This commit is contained in:
parent
5e509284b1
commit
66451e3287
5 changed files with 53 additions and 12 deletions
12
configs.yml
12
configs.yml
|
@ -1,12 +0,0 @@
|
|||
etckeeper:
|
||||
- install:
|
||||
- etckeeper
|
||||
- run:
|
||||
- sudo git config --global user.name "root@$(uname -n)";
|
||||
sudo git config --global user.email "root@$(uname -n)";
|
||||
sudo git config --global init.defaultBranch "main"
|
||||
- run:
|
||||
command: sudo etckeeper init
|
||||
condition: "[ ! -d /etc/.git ]"
|
||||
- run:
|
||||
- sudo etckeeper commit "First commit"
|
|
@ -31,3 +31,4 @@
|
|||
- { role: rsync-backup, tags: rsync-backup }
|
||||
- { role: gitea-backup, tags: gitea-backup }
|
||||
- { role: gaming, tags: gaming }
|
||||
- { role: etckeeper, tags: etckeeper }
|
||||
|
|
3
roles/etckeeper/meta/main.yml
Normal file
3
roles/etckeeper/meta/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
dependencies:
|
||||
- role: check-sudo
|
44
roles/etckeeper/tasks/main.yml
Normal file
44
roles/etckeeper/tasks/main.yml
Normal file
|
@ -0,0 +1,44 @@
|
|||
---
|
||||
- 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"
|
5
roles/etckeeper/templates/gitconfig.j2
Normal file
5
roles/etckeeper/templates/gitconfig.j2
Normal file
|
@ -0,0 +1,5 @@
|
|||
[user]
|
||||
name = root@{{ ansible_hostname }}
|
||||
email = root@{{ ansible_hostname }}
|
||||
[init]
|
||||
defaultBranch = main
|
Loading…
Add table
Reference in a new issue