Add role to install dotfiles and apply them

This commit is contained in:
2025-09-13 02:45:44 +02:00
parent 25dc798c0c
commit 54fb4d3262
3 changed files with 28 additions and 0 deletions

View 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

View 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