Skip to content

Installs chezmoi and your preferred dotfiles repository using Ansible role on macOS or Linux.

License

Notifications You must be signed in to change notification settings

wayofdev/ansible-role-dotfiles

Repository files navigation




Build Status Ansible Role Latest Version Ansible Quality Score Ansible Role Software License Commits since latest release

Ansible Role: Chezmoi for macOS

Role is used to automate installation and setup of chezmoi on macOS, Ubuntu and Debian systems.

If you like/use this role, please consider starring it. Thanks!


β†’ Why should I use a dotfile manager?

Dotfile managers give you the combined benefit of a consistent environment everywhere with an undo command and a restore from backup.

As the core of our development environments become increasingly standardized (e.g. using git at both home and work), and we further customize them, at the same time we increasingly work in ephemeral environments like Docker containers, virtual machines, and GitHub Codespaces.

In the same way that nobody would use an editor without an undo command, or develop software without a version control system, chezmoi brings the investment that you have made in mastering your tools to every environment that you work in.

β†’ Why Chezmoi for dotfiles?

When I decided to develop a role for my dotfiles I did some research over existing dotfile managers. Chezmoi has a great comparison table over other managers. Check this comparison table.


πŸ“‘ Requirements

  • Homebrew: Requires homebrew already installed (you can use wayofdev.homebrew to install it on your macOS).
  • Up-to-date version of ansible. During maintenance/development, we stick to ansible versions and will use new features if they are available (and update meta/main.yml for the minimum version).
  • Compatible OS. See compatibility table.
  • Role has dependencies on third-party roles on different operating systems. See requirements.yml and dependencies section.

πŸ”§ Role Variables

Available variables are listed below, along with example values (see defaults/main.yml):


β†’ Structure

# From where should we take dotfiles?
# Example repository: "https://github.com/benmezger/dotfiles"
# By default, my personal is used.
dotfiles_repository_url: "https://github.com/lotyp/dotfiles.git"
dotfiles_repository_branch: master

πŸ“— Example Playbook

---
- hosts: all

  # is needed when running over SSH
  environment:
    - PATH: "/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:{{ ansible_env.PATH }}"

  roles:
    - wayofdev.homebrew
    - wayofdev.dotfiles

βš™οΈ Development

To install dependencies and start development you can check contents of our Makefile

Install poetry using poetry-bin and all dev python dependencies:

$ make install

Install only python dependencies, assuming that you already have poetry:

$ make install-deps

Install all git hooks:

$ make hooks

Lint all role files:

$ make lint

πŸ§ͺ Testing

You can check Makefile to get full list of commands for remote and local testing. For local testing you can use these comands to test whole role or separate tasks:

β†’ on localhost

⚠️ Notice: By defaut all tests are running against your local machine!

# run molecule tests on localhost
$ poetry run molecule test --scenario-name default-macos-on-localhost -- -vvv

# or with make command
$ make m-local

# choose which tags will be included
$ export TASK_TAGS="dotfiles-install,dotfiles-configure"; make m-local

# runs molecule with docker driver
$ poetry run molecule test --scenario-name default -- -vvv

# or with make file
$ make m-linux

β†’ over SSH

# run molecule scenarios against remote machines over SSH
# this will need VM setup and configuration
$ poetry run molecule test --scenario-name default-macos-over-ssh -- -vvv

$ make m-remote

# tags also can be passed
$ export TASK_TAGS="dotfiles-install,dotfiles-configure"
$ make m-remote

πŸ“¦ Dependencies

Installation handled by Makefile and requirements are defined in requirements.yml

β†’ for all

β†’ only macOS

β†’ only Linux


🧩 Compatibility

This role has been tested on these systems:

system / container tag
macos monterey
macos big-sur
ubuntu latest
debian latest

🀝 License

Licence


πŸ™†πŸΌβ€β™‚οΈ Author Information

This role was created in 2022 by lotyp / wayofdev.


🫑 Contributors