Skip to content

singleplatform/mac-dev-playbook

 
 

Repository files navigation

Mac Development Ansible Playbook

Build Status

This utility installs and configures the minimal software on your Mac needed for development at SinglePlatform. The following tasks are performed:

  • Installs minimal bash profile (preserves any bash profile customizations you may have)
  • Installs useful git config with some handy aliases (see files/gitconfig)
  • Optionally installs your dotfiles from a github repo
  • Optionally tweaks many aspects of macOS for better performance and ease of use.
  • Optionally installs apps form the Apple Store
  • Installs Homebrew with minimal set of packages useful for SP development
  • Installs python 2.7 using pyenv
  • Clones SP repos into (~/envs):
    • ansible
    • cdef
    • paywall
    • publisher-feeds
    • single-api
    • sp-perftest
    • spbilling
    • spdj
    • spfb
    • spv2
  • Sets up ansible, virtualbox, and vagrant so that starting a dev environment should be as simple as: cd ~/envs/ansible vagrant up spdj

It can also be used to install a battery of optional software which many developers find useful.

This is a work in progress. I'll be evolving this set of playbooks over time.

See also:

Installation

  1. You need access to to the Singleplatform GitHub Organization via SSH Key before this utility will function.
    • If you're upgrading to a new laptop, make sure you copy all the files from your old ~/.ssh laptop before running this. I recommend using AirDrop for this task.
    • If you are installing this for the first time, you'll need to upload your key here https://github.com/settings/keys.
  2. Clone this repository to your local drive. I recommend putting it in ~/envs.
  3. Run $ ./install.sh from the cloned repo. This will open an editor with the default config loaded.
    • At a minimum, you need to fill out "full_name" & "email_address".
  4. Once you save this file, the ansible playbook will be invoked. Enter your network account password when prompted for Sudo.

Notes:

  • The install.sh command can be re-run and will use your saved settings. If you wish to change your configuration after the first run, you'll need to edit: ~/.config/mac-dev-playbook
  • If some Homebrew commands fail, you might need to agree to Xcode's license or fix some other Brew issue. Run brew doctor to see if this is the case.

Running a specific set of tagged tasks

You can filter which part of the provisioning process to run by specifying a set of tags using ansible-playbook's --tags flag. The tags available are dotfiles, homebrew, mas, extra-packages and osx.

./install.sh --tags "dotfiles,homebrew"

Included Applications / Configuration (Default)

Applications (installed with Homebrew Cask):

  • aws-vault
  • font-dejavusansmono-nerd-font
  • font-droidsansmono-nerd-font
  • font-hack-nerd-font
  • github
  • hipchat
  • iterm2
  • mysql-client
  • mysql-connector-python
  • postman
  • utc-menu-clock
  • Vagrant
  • virtualbox

Packages (installed with Homebrew):

  • autoconf
  • awscli
  • bash-completion
  • ccache
  • coreutils
  • gettext
  • git
  • git-secrets
  • gpg
  • openssl
  • pwgen
  • pyenv
  • pyenv-ccache
  • pyenv-pip-migrate
  • pyenv-virtualenv
  • readline
  • sqlite
  • tmux
  • tmux-cssh
  • vagrant-completion

Overriding Defaults

Not everyone's development environment and preferred software configuration is the same.

You can override any of the defaults configured in ~/.config/mac-dev-playbook. For example, you can install additional packages and apps with something like:

homebrew_additional_packages:
  - cowsay
  - go

homebrew_cask_additional_apps:
  - datagrip
  - pycharm
  
mas_additional_installed_apps:
  - { id: 443987910, name: "1Password" }
  - { id: 498486288, name: "Quick Resizer" }
  - { id: 557168941, name: "Tweetbot" }
  - { id: 497799835, name: "Xcode" }

composer_additional_packages:
  - name: hirak/prestissimo
  - name: drush/drush
    version: '^8.1'

gem_additional_packages:
  - name: bundler
    state: latest

npm_additional_packages:
  - name: webpack

pip_additional_packages:
  - name: mkdocs

If you have a repository of dotfile customizations on GitHub, you can automatically pull those files down by setting something like this:

dotfiles_repo: https://github.com/davidpanofsky/dotfiles.git
dotfiles_files:
  - .bash_profile
  - .gitconfig
  - .gitignore
  - .SpaceVim.d/init.vim
  - .osx

Optional Applications

Applications (installed with Homebrew Cask):

  • adobe-acrobat-pro
  • adobe-acrobat-reader
  • air-connect
  • amethyst
  • android-file-transfer
  • android-platform-tools
  • chrome-devtools
  • chrome-remote-desktop-host
  • cyberduck
  • datagrip
  • Docker
  • docker-toolbox
  • Dropbox
  • Firefox
  • gitup
  • Google Chrome
  • google-drive-file-stream
  • jira-client
  • lastpass
  • macpass
  • mysql-shell
  • mysql-utilities
  • mysqlworkbench
  • noti
  • pycharm
  • redis-app
  • rsyncosx
  • spotify
  • sqlexplorer
  • sqlworkbenchj
  • Sublime Text
  • time-out
  • vagrant-manager
  • virtualc64
  • wireshark
  • xaos

Packages (installed with Homebrew):

  • ack
  • fd
  • fdupes
  • fontconfig
  • fzf
  • gnu-sed
  • httpie
  • jq
  • lftp
  • links
  • nmap
  • parallel
  • psutils
  • pv
  • ssh-copy-id
  • sslscan
  • tcptraceroute
  • watch
  • wget

Future additions

Things that still need to be done manually

It's my hope that I can get the rest of these things wrapped up into Ansible playbooks soon, but for now, these steps need to be completed manually (assuming you already have Xcode and Ansible installed, and have run this playbook).

  1. Set JJG-Term as the default Terminal theme (it's installed, but not set as default automatically).
  2. Install Sublime Package Manager.
  3. Install all the apps that aren't yet in this setup (see below).
  4. Remap Caps Lock to Escape (requires macOS Sierra 10.12.1+).
  5. Set trackpad tracking rate.
  6. Set mouse tracking rate.
  7. Configure extra Mail and/or Calendar accounts (e.g. Google, Exchange, etc.).

Applications/packages to be added:

These are mostly direct download links, some are more difficult to install because of custom installers or other nonstandard install quirks:

Configuration to be added:

  • I have vim configuration in the repo, but I still need to add the actual installation:
    mkdir -p ~/.vim/autoload
    mkdir -p ~/.vim/bundle
    cd ~/.vim/autoload
    curl https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim > pathogen.vim
    cd ~/.vim/bundle
    git clone git://github.com/scrooloose/nerdtree.git
    

Testing the Playbook

Many people have asked me if I often wipe my entire workstation and start from scratch just to test changes to the playbook. Nope! Instead, I posted instructions for how I build a Mac OS X VirtualBox VM, on which I can continually run and re-run this playbook to test changes and make sure things work correctly.

Additionally, this project is continuously tested on Travis CI's macOS infrastructure.

Ansible for DevOps

Check out Ansible for DevOps, which teaches you how to automate almost anything with Ansible.

Author

Jeff Geerling, 2014 (originally inspired by MWGriffin/ansible-playbooks).

Troubleshooting

  • If you are running the installation script on macOS 11 (BigSur) you will most likely encounter an error while installing python 3.6.8 in pyenv. Error will look similar to the following:

    ./Modules/posixmodule.c:9221:15: error: implicit declaration of function 'sendfile' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
            ret = sendfile(in, out, offset, &sbytes, &sf, flags);
    

    If his is the case, please run the following command:

    CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.8 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
    

    Then re-run $ ./install.sh

About

Mac setup and configuration via Ansible.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 37.7%
  • Jinja 33.5%
  • Shell 20.8%
  • Vim Script 8.0%