Installs a set of dotfiles from a given Git repostiory.
Works for all dotfile repos that follow the stow format (blog post).
---
- hosts: localhost
roles:
- role: idolize.dotfiles_stow
vars:
dotfiles_repo: https://github.com/myusername/mydotfiles
dotfiles_conflict_mode: adopt_and_reset
Before using the role, you must define the dotfiles_repo
variable somewhere. This is the git repo where your dotfiles are stored (e.g. "https://github.com/myusername/mydotfiles
").
You may also specify dotfiles_repo_version
(default = "main"), which specifies the version
of the repo to checkout (e.g. branch, tag, or commit).
The dotfiles repository clone location and dotfiles symlink destination can be configured using the following variables:
dotfiles_repo_local_destination
(default = "~/dotfiles") - Where to clone the dotfiles_repo
git repository (the source stow directory).
dotfiles_home
(default = "~") - Where to symlink the final dotfiles (stow's target directory).
If there are already existing configuration files in the dotfiles_home
target directory then, by default, the task will throw an error. This matches the default behavior of stow.
If, instead, you want to change the behavior of how conflicts are handled you can set the dotfiles_conflict_mode
variable to one of the following options:
abort
(default) - Throws an error and exits on conflict.
adopt
- Follows the "adopt" behavior from stow, where the existing config files overwrite the ones in the dotfiles repo.
adopt_and_reset
- This is semi-equivalent to overwriting the existing config files with the ones from the dotfiles_repo
, but there are a few caveats to be aware of. Instead of directly overwriting the files, it instead runs using --adopt
, and then resets the dotfiles_repo
repo back to the previous state using git.
None
Fully tested on:
- Fedora 36
- Ubuntu 20.04
- macOS 13.4.1
Forked from: https://github.com/mariuskimmina/ansible-role-dotfiles
Inspired by: https://github.com/geerlingguy/ansible-role-dotfiles. The main difference between the original project and this one is the usage of stow.