Skip to content

Instantly share code, notes, and snippets.

@clifferson
Last active December 27, 2015 15:09
Show Gist options
  • Save clifferson/7345596 to your computer and use it in GitHub Desktop.
Save clifferson/7345596 to your computer and use it in GitHub Desktop.
Using shell to install chef to use ruby to configure your mac!

What?

Use chef-solo driven by soloist to apply recipes to a mac and configure it just how you like.

bit.ly/chef4mac < this presentation (meta)

What is chef-solo and soloist

  • chef-solo : Dont concern yourself with this much?

  • soloist : Nicely abstracted chef-solo manager gem, hooray.

    • Powered by the soloistrc yaml manifest.
    • Uses librarian-chef to gather cookbook deps from the Cheffile.

soloistrc

recipes:
- pivotal_workstation::create_var_chef_cache
- sprout-osx-apps::chrome
- sprout-osx-apps::dropbox
- sprout-osx-apps::flux
- sprout-osx-apps::adium
- sprout-osx-apps::vagrant
- sprout-osx-apps::sizeup
- workstation::spotify
- workstation::install_dotfiles
- workstation::install_dotvim
- workstation::link_library_things
- workstation::link_ssh_things

Node attributes

recipes:
- cookbook-name::recipe-name
 node_attributes:
   rbenv:
     rubies:
       1.9.3-p362
     default_ruby: 1.9.3-p362

Cheffile

site 'http://community.opscode.com/api/v1'

cookbook 'sprout-osx-base',
  :git => 'git://github.com/pivotal-sprout/sprout.git',
  :path => 'sprout-osx-base'

cookbook 'pivotal_workstation',
  :git => 'git://github.com/pivotal-sprout/sprout.git',
  :path => 'pivotal_workstation'

cookbook 'sprout-osx-apps',
  :git => 'git://github.com/pivotal-sprout/sprout.git',
  :path => 'sprout-osx-apps'

cookbook 'workstation',
  :git => "git://github.com/clifferson/workstation-cookbook.git"

cookbook 'homebrew',
  :git => "git://github.com/clifferson/homebrew-cask-cookbook.git"

Recipes & Attributes

sprout-osx-apps/recipes/chrome.rb

dmg_properties = node['sprout']['chrome']['dmg']

dmg_package "Google Chrome" do
  dmg_name    dmg_properties['dmg_name']
  source      dmg_properties['source']
  checksum    dmg_properties['checksum']
  action :install
  owner node['current_user']
end

sprout-osx-apps/attributes/chrome.rb

default['sprout']['chrome']['dmg']['source']      = 'https://dl.google.com/chrome/mac/stable/CHFA/googlechrome.dmg'
default['sprout']['chrome']['dmg']['checksum']    = '5cb154403f1e638b9bcca68c0c80dc2b562e9d3a14c7db3e370428dcd451891a'
default['sprout']['chrome']['dmg']['dmg_name']    = 'googlechrome'

Lets install some software!

Non Contrived example + boot strap script.

Resources

Possible better ways of doing this?

Picks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment