Rocu.de

Love, caffeine and omlette

Tag: devops

Manage your Mac Apps with homebrew-cask

A while ago I became interested in automating the setup of my Macs. I started my journey with chef-solo, however this wasn't really practical for me, so I switched to homesick to manage my dotfiles.

Unfortunately that left me without a solution to install my apps automatically.

Not any more. homebrew-cask to the rescue!

Take a walk

Image Source: Flickr/megoizzy (CC BY-SA 2.0)

What is homebrew-cask

homebrew-cask is a Homebrew extension that allows you to install your apps like this:

brew cask install evernote

How to install homebrew-cask

If you already use homebrew, installing homebrew-cask is really simple:

brew tap phinze/homebrew-cask
brew install brew-cask

If you have Alfred installed you should also configure it, so that it recognizes apps managed by homebrew-cask.

brew cask alfred link

Using homebrew-cask

Using homebrew-cask is simple. You install apps using the brew cask install command. Evernote for example, you would install like this:

brew cask install evernote

Create a little script to install your Apps

I store all my apps in a file called ~/.brew. In order to install the apps I just have to run it.

This is how you create your own:

touch ~/.brew
chmod +x ~/.brew

Now fill it with the Apps you want to install across all your Mac's.

For me this looks like:

#!/bin/bash
brew cask install google-chrome  
…
brew cask install rubymine  
brew cask install charles  
brew cask install mou  
brew cask install bit-torrent-sync  

I have this file on GitHub and symlink it with homesick. When I am on a new Mac I just have to run

~/.brew

That installs all my common apps.

Create own casks

There are over 300 casks available already. You can view a list with

brew cask search

If your favorite app is missing it is really simple to add it.

In the example below I create a Cask for Soulver.

brew cask create soulver

An editor opens with the newly generated cask.

class Soulver < Cask  
   url ''
   homepage ''
   version ''
   sha1 ''
   link ''
end  

You just have to fill in the download URL of the app, the apps name, the version, the sha1 checksum of the download and it's homepage.

class Soulver < Cask  
  url 'http://www.acqualia.com/files/download.php?product=soulver'
  homepage 'http://www.acqualia.com/soulver/'
  version 'latest'
  no_checksum
  link 'Soulver.app'
end  

In Soulver's case the download URL does always refer to the latest version. So in this case I used no_checksum, so that this Cask will not break in the future.

Now audit your cask:

$ brew cask audit soulver
audit for soulver: passed

Now you can install Soulver. And don't forget to open a pull request 😉

Before you do — check the latest contribution guidelines.

Conclusion

I am really happy that homebrew-cask exists now. It closed a gap in my configuration management. I can set up a new Mac in no time. I hope you enjoy it as much as I do.

Command line tapas: Feel like a hacker with cluster ssh

A few months ago I paired on a chef recipe with a colleague. After we
uploaded the cookbook we wanted to try this stuff out on a few nodes.

Until then I would have kind of done it completely manually. But he
entered a command and the following happend:

ClusterSSH in action

Wow. He just ssh'ed into all of these servers. The next part looked even
cooler. He started typing and magically the text appeared in all the
terminals. He pressed enter and the chef run started. It looked awesome. Chef runs produce quite a lot of text 😉

I was hooked and asked him what he just did. "That's just ClusterSSH", he
replied, "I use it all the time".

ClusterSSH is a tool for making the same change on multiple servers at
the same time. The 'cssh' command opens an administration console and
an xterm to all specified hosts. Any text typed into the
administration console is replicated to all windows. All windows may
also be typed into directly.

For the Mac there is a similar tool called csshx thats what I ended
up using.

It works like a charm. You just specify your clusters in a clusterfile.

cluster1 host1 host2
cluster2 host3 host4

Now you just enter:

csshx cluster1

That's it.

I use csshx during every maintainance window. I love
pair programming. Makes you realize that things that are obvious to
yourself are not obvious to your colleagues.

© 2017 Rocu.de

Theme by Anders NorenUp ↑