wayofdev / ansible-role-dotfiles

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

Home Page:https://wayof.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool




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


About

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

https://wayof.dev

License:GNU General Public License v3.0


Languages

Language:Makefile 100.0%