Add role to install dotfiles and apply them
This commit is contained in:
2
main.yml
2
main.yml
@@ -9,6 +9,8 @@
|
||||
when: ansible_os_family == 'Debian'
|
||||
- role: roles/ssh
|
||||
tags: [ssh]
|
||||
- role: roles/dotfiles
|
||||
tags: [dotfiles]
|
||||
tasks:
|
||||
- name: Dump hostvars
|
||||
tags: [never, dump]
|
||||
|
||||
8
roles/dotfiles/files/pre-commit-hook.sh
Normal file
8
roles/dotfiles/files/pre-commit-hook.sh
Normal file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
git status --short | grep -E '^D|^R' | sed 's/...//;s/ -> .*//' | while read f
|
||||
do
|
||||
test -L "$HOME/$f" && rm "$HOME/$f"
|
||||
done
|
||||
18
roles/dotfiles/tasks/main.yml
Normal file
18
roles/dotfiles/tasks/main.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
- name: Ensure dotfiles directory
|
||||
git:
|
||||
repo: git@gitea.nehrke.info:nemoinho/dotfiles.git
|
||||
dest: "{{ lookup('env', 'HOME') ~ '/dotfiles' }}"
|
||||
|
||||
- name: Ensure pre-commit hook to automatically remove links of deleted dotfiles
|
||||
copy:
|
||||
src: pre-commit-hook.sh
|
||||
dest: "{{ lookup('env', 'HOME') ~ '/dotfiles/.git/hooks/pre-commit' }}"
|
||||
mode: u=rwx,g=rx,o=r
|
||||
|
||||
- name: Ensure dotfiles are up-to-date
|
||||
shell: |
|
||||
stow --adopt .
|
||||
[ -n "$(git status --short)" ] && git stash || true
|
||||
args:
|
||||
chdir: "{{ lookup('env', 'HOME') ~ '/dotfiles' }}"
|
||||
executable: /bin/bash
|
||||
Reference in New Issue
Block a user