Nick Hammond

Software Developer, Cyclist, & Traveler.

Automating application installs with Ansible on OS X

On OSX to install most applications you download a .pkg or .dmg file, open it and then you need to drag it to your Applications folder.

Some applications have moved to the app store which makes installing them just a click of a button. For the other applications that haven’t done that yet, there’s a much easier way with Homebrew Cask.

It’s just as easy to make it a bit more automated with Ansible and the brew_cask module.

Start working on your playbook file(applications.yml):


---
- hosts: localhost
  tasks:
    - name: Install Virtualbox and Vagrant via brew cask
      homebrew_cask: name={{ item }}
      with_items:
        - virtualbox
        - vagrant

Now run this locally by specifying a local connection and localhost:

ansible-playbook -i "localhost," -c local applications.yml
➜  ansible git:(master) ✗ ansible-playbook -i "localhost," -c local applications.yml

PLAY [localhost] **************************************************************

GATHERING FACTS ***************************************************************
ok: [localhost]

TASK: [Install Virtualbox & Vagrant via cask] *********************************
changed: [localhost] => (item=virtualbox)
changed: [localhost] => (item=vagrant)

PLAY RECAP ********************************************************************
localhost                  : ok=0    changed=2    unreachable=0    failed=0

You can pull the cask items out of the playbook too and store them in a vars file to clean things up a bit. This is also a really easy win with Ansible to get going on your local machine instead of having to keep track of what’s been installed. Even if you just use the cask command to install applications it’s a nice little time saver.

Botkit

I’ve always been fascinated with simple messaging systems. Back when SMS was the primary text message platform I worked with an agency to build various text based projects.

Resolving .dev to Localhost With Ansible & Nginx on OS X

When developing locally it’s nice to be able to have multiple applications running at once and at pre-determined local domains. The /etc/hosts is one of the simplest ways to configure this but you have to modify it each time you’d like to add a new domain for local development. Pow.cx made this incredibly easy for a while but the better approach is to be able to have a similar environment to what you’re running in production. Nginx is really easy to get up and running with and nice to work with so I’ll be using that.