Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.

Personal Module Recipes

Lyza Gardner edited this page Nov 16, 2015 · 13 revisions

Homebrew packages

As brew is the default provider for puppet packages in boxen, you can manage your own homebrew stuff with a simple addition to your module:

  package {
    ['mongodb',
     'anotherExamplePackage']:
  }

Particular Homebrew Packages

Of particular interest may be the pandoc package, which is required to build could-four-dot-com, our website. Here is the line to add if you're not going to add it to the above structure:

package {
  'pandoc':
  ensure => installed
}

Note that this pulls in the complete Haskell platform, which takes about two hours to compile on a 2013 Macbook Air, so plan accordingly.

System Config

You can use the osx puppet module to set some nice OS defaults.

To enable a setting, you can include the resource like this (each include turns that feature "on"):

  # OS X defaults
  include osx::global::disable_autocorrect
  include osx::dock::autohide
  include osx::finder::show_all_on_desktop
  include osx::finder::unhide_library
  include osx::finder::show_hidden_files
  include osx::finder::show_all_filename_extensions
  include osx::safari::enable_developer_mode

Or, to set parameters on an OS setting:

  class { 'osx::dock::icon_size':
    size => 42
  }

  class { 'osx::dock::magnification':
    magnification => true,
    magnification_size => 60
  }

OS X module full documentation

Ruby Gems

The following is from @grigs personal module.

  # Twurl
  ruby_gem { 'Twurl':
    gem          => 'twurl',
    version      => '~> 0.9',
    ruby_version => '*',
  }

Dotfiles

Managing dotfiles with homeshick is pretty easy. More about homeshick

  1. Create a repository to hold your dotfiles. Everything in the home directory will be symlinked into your actual user directory. See lyzadanger/dotfiles for a starting point.
  2. Include the recipe below in your personal module. Edit the repository name for your dotfiles. That's it!
  # Make sure this is set somewhere before the dotfiles stuff
  $HOME = "/Users/${::boxen_user}"
  #
  # DOTFILES
  #  - install and use homeshick for managing dotfiles
  #  - install my dotfiles
  # Inspired by https://github.com/mroth/my-boxen/blob/master/modules/people/manifests/mroth.pp
  #
  file { 'homeshickdir':
    path => "${HOME}/.homesick/repos",
    ensure => directory
  }

  repository { 'homeshick':
    source => 'andsens/homeshick',
    path   => "${HOME}/.homesick/repos/homeshick",
    require => File['homeshickdir']
  }
  repository { 'my-dotfiles':
    ensure  => 'origin/HEAD', # https://github.com/boxen/puppet-repository/issues/12
    source  => 'lyzadanger/dotfiles', # Change me
    path    => "${HOME}/.homesick/repos/dotfiles",
    require => File['homeshickdir'],
    notify  => Exec['link-dotfiles']
  }

  exec { 'link-dotfiles':
    command     => "bash -c 'source ${HOME}/.homesick/repos/homeshick/homeshick.sh; homeshick link dotfiles --force'",
    #refreshonly => true
  }

Note that in my copy I have refreshonly => true commented out. In an ideal world, your dotfiles symlinking would only happen when your dotfiles repo had a material change, right? Except that in my case, I do my local dotfiles work in that same directory. Meaning that often pulling the repo from origin looks identical to my local and doesn't trigger the linking even when it actually needs to. That is, my local won't trigger a refresh event for puppet even when "there are changes that need to be linked".

Global npm packages

You might consider using boxen to manage your global npm packages. No need to use it on a project-by-project level. First check the main site.pp and cloudfour modules to make sure the npm module in question isn't already included. Then you can add something like:

npm_module { 'browserify for 0.10': 
  module => 'browserify', 
  node_version => '0.10' 
}

Make sure to match the node_version to whatever your used global version is (at time of writing it's 0.10 for us; we follow github's upstream lead on this one).

Note: Due to a breaking change to the puppet-nodejs API, the old syntax for defining NPM modules no longer works:

  • npm packages are installed with npm_module instead of nodejs::module
  • node versions are defined without the leading v (0.10.36 instead of v0.10.36)

Project-specific Node versions

If you need to use a different version of Node for a project, you can do so by adding something like this to your manifest:

nodejs::local { '/absolute/path/to/your/project':
  version => '0.12'
}

The version specified should be one of the versions defined in site.pp.

Finding more boxens

You might want something that goes beyond a homebrew, npm, or ruby gem install.

Head over to the boxen user's list of repos and see if you can locate what you're looking for here. Using a pre-existing boxen puppet-* module is usually straightforward. See instructions for updating the config but note that the target module will be your personal module, not the cloudfour company module.

It's also not too hard, in some cases, to whip up custom modules, but that's an exercise for the reader.

Clone this wiki locally