Sitelet https://github.com/koolwilly72/mac-setup
Skip to content

Repository files navigation

Mac Setup

Ansible macOS License

Automated setup for macOS development environment using Ansible. This playbook configures a fresh any Mac with development tools, applications, and sensible defaults.

Features

  • Homebrew Package Management - CLI tools and GUI applications
  • Development Environment - Languages, Git config, SSH keys
  • macOS System Preferences - Dock, Finder, keyboard, trackpad settings
  • Dotfiles Management - Clone and symlink your dotfiles
  • Fully Customizable - Everything configured via variables

Quick Start

Prerequisites

  • macOS Ventura (13.0) or later
  • Command Line Tools for Xcode
xcode-select --install

Installation

  1. Clone this repository:
git clone https://github.com/koolwilly72/mac-setup.git
cd mac-setup
  1. Install Ansible:
# Using Homebrew (if already installed)
brew install ansible

# Or using pip
pip3 install --user ansible
  1. Install required Ansible collections:
ansible-galaxy install -r requirements.yml
  1. Customize your configuration:
cp group_vars/all.yml group_vars/all.yml.bak
# Edit group_vars/all.yml with your preferences
  1. Run the playbook:
ansible-playbook site.yml -K

The -K flag prompts for your sudo password (required for some operations).

Configuration

All configuration is done in group_vars/all.yml. Key sections include:

Homebrew Packages

homebrew_packages:
  - git
  - neovim
  - tmux

GUI Applications (Casks)

homebrew_casks:
  - visual-studio-code
  - docker
  - slack

Development Languages

development_languages:
  - python@3.12
  - node
  - go

Git Configuration

git_user_name: "Your Name"
git_user_email: "your.email@example.com"

macOS Preferences

macos_dock_autohide: true
macos_finder_show_hidden: true
macos_key_repeat_rate: 2

Dotfiles

dotfiles_repo: "https://github.com/koolwilly72/dotfiles.git"
dotfiles_symlink: true

Usage

Run Everything

ansible-playbook site.yml -K

Run Specific Roles

# Only install Homebrew packages
ansible-playbook site.yml --tags homebrew -K

# Only configure macOS defaults
ansible-playbook site.yml --tags macos -K

# Only setup development tools
ansible-playbook site.yml --tags development -K

Check Mode (Dry Run)

ansible-playbook site.yml --check -K

Verbose Output

ansible-playbook site.yml -K -vvv

Project Structure

mac-setup/
├── site.yml                    # Main playbook
├── requirements.yml            # Ansible Galaxy dependencies
├── group_vars/
│   └── all.yml                 # Configuration variables
├── inventory/
│   └── hosts                   # Inventory file
└── roles/
    ├── homebrew/               # CLI package management
    ├── apps/                   # GUI applications
    ├── development/            # Languages & dev tools
    ├── dotfiles/               # Dotfile management
    └── macos-defaults/         # System preferences

Customization Examples

Adding Mac App Store Apps

First, find the app ID using mas:

brew install mas
mas search "App Name"

Then add to group_vars/all.yml:

mas_apps:
  - id: 497799835
    name: "Xcode"
  - id: 803453959
    name: "Slack"

Adding Homebrew Taps

homebrew_taps:
  - homebrew/cask-fonts
  - hashicorp/tap

Custom Python/Node Packages

python_packages:
  - black
  - poetry
  - django

node_packages:
  - yarn
  - nx
  - vercel

Idempotency

This playbook is idempotent—running it multiple times will not cause issues. It will only make changes when necessary.

Troubleshooting

Permission Denied

Some operations require sudo. Always run with -K:

ansible-playbook site.yml -K

Homebrew Issues

If Homebrew fails, ensure it's properly installed:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Collection Not Found

Install required collections:

ansible-galaxy install -r requirements.yml --force

Cask Already Installed

Some casks might fail if already installed via other means. These errors are ignored by default.

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -m 'Add new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Inspired by various dotfile and Mac setup repositories
  • Built with Ansible
  • Uses Homebrew for package management

Related Projects

About

Ansible playbook for automated macOS development environment setup

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages