This Ansible playbook installs and configures software and utilities for a DevOps environment on macOS.
Clone this repository on your Mac, then install Ansible:
brew install ansibleCopy the example config and fill in your values:
cp config.local.yml.example config.local.ymlEdit config.local.yml. Passphrases (gpg_key_passphrase, ssh_key_passphrase) are only required on first run — once keys are generated and stored in macOS Keychain, they can be removed. It is recommended to encrypt the file:
ansible-vault encrypt config.local.ymlansible-playbook setup-my-mac.yml -i inventoryWith an encrypted config.local.yml:
ansible-playbook setup-my-mac.yml -i inventory --ask-vault-passTo preview changes without applying them (dry-run):
ansible-playbook setup-my-mac.yml -i inventory --check --diffUse -K only when running tasks that require privilege escalation.
Run only the GPG role:
ansible-playbook setup-my-mac.yml -i inventory --tags gpgRun only the SSH role:
ansible-playbook setup-my-mac.yml -i inventory --tags sshRun only the GitHub key upload role:
ansible-playbook setup-my-mac.yml -i inventory --tags github_keysUploading keys to GitHub requires extra gh CLI token scopes:
gh auth refresh -h github.com -s write:gpg_key
gh auth refresh -h github.com -s admin:public_keyFor GitHub Enterprise, replace github.com with your enterprise hostname.
The full list of packages is in config.yml. In summary:
-
Homebrew — installs packages, casks and taps (Docker, Slack, VSCode, iTerm2, …)
-
Dotfiles — renders templates from
roles/setup_dotfiles/templates/into~/dotfilesand symlinks them into$HOME. Add a template file there and it is deployed automatically. -
GPG key — generates an ed25519 GPG key using
gpg_key_nameandgpg_key_emailfromconfig.local.yml. Passphrase is stored in macOS Keychain on first run.gitconfig_signingkeyin.gitconfigis resolved automatically from the keyring — no manual fingerprint copy required. -
SSH key — generates a key at
~/.ssh/{{ ssh_key_name }}. Passphrase is added to macOS Keychain on first run. Setssh_key_nameinconfig.local.ymlto choose the filename. -
GitHub keys — uploads GPG and SSH public keys to GitHub using the
ghCLI. Enableconfigure_github_enterprise_keysand setgithub_enterprise_hostnameto also upload to a GitHub Enterprise instance. -
Terminal — installs oh-my-zsh.
-
macOS preferences — sets system defaults (Finder, screenshots, Dock, etc.).