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.