Pro Yearly is on sale from $80 to $50! »

BOXEN

 BOXEN

At GitHub, we've been growing pretty quickly and that sort of growth presents a lot of challenges. We were feeling the pain of trying to teach everyone (developers and designers alike) how to get GitHub and all our other projects running on their laptops. The process was failure-prone, complex, and time-consuming. So, last summer, we created the first iteration of The Setup — GitHub's method of managing laptops without getting all authoritarian about it. We quickly realized that other organizations needed and wanted this environment, so we started back with the basics and re-architected The Setup into Boxen. The same tool, the same method, but written for modularity and general consumption.

We’ve since released Boxen (as of February 2013). This talk covers what Boxen is, some of the design choices involved, how to get running with Boxen, and more.

Cd839cc361ffa996be0cc8259f3d7555?s=128

Will Farrington

February 21, 2013
Tweet

Transcript

  1. BOXEN

  2.  wfarr

  3.  ops

  4.  friction

  5. what is a boxen?

  6. Ruby Framework

  7. @jbarnette + @wfarr

  8. when two developers get really angry at how awful a

    bunch of things are, they write code
  9. Boxen is a framework

  10. Boxen is a standard library

  11. Boxen is a philosophy on how your machine should be

    configured
  12. Boxen tries to make installing system dependencies, configuring your machine,

    and generally everything easier and automated
  13. why should i use boxen?

  14. shipping day one

  15. It's my first day at company X. So excited to

    work on $THING!
  16. Ohai new laptop! I'm gonna spend the next like three

    days configuring you in the best way I can and hopefully I can write some code soon
  17. Ohai new laptop! I'm gonna spend the next like three

    days configuring you in the best way I can and hopefully I can write some code soon lame
  18. 1. open boxen-web 2. run the command 3. ship code

  19. constant updates

  20. "Only run this once and if anything breaks just reformat

    and do it again from scratch."
  21. "Only run this once and if anything breaks just reformat

    and do it again from scratch." lame
  22. Want to know how GitHub tested ruby 1.9.3 in development?

  23. I pushed an update to Boxen.

  24. And then I sent an email and said "Hey, this

    is changing, here's why, and it'll happen the next time you run Boxen. That's it. Easy."
  25. The next time they ran Boxen, it installed our custom

    Ruby 1.9.3 build, configured their local github.com to use it, and everything from there just worked
  26. If you make updating hard, people won't update.

  27. If people don't update, you lack consistency between development and

    production.
  28. If you lack consistency in development and production, you're going

    to have a bad time.
  29. security

  30. zomg java is hella unsafe in safari because <%= reason

    %>
  31. so let's send an email and maybe people will read

    it and maybe they will disable java in safari and maybe life will go on
  32. so let's send an email and maybe people will read

    it and maybe they will disable java in safari and maybe life will go on lame
  33. None
  34. Now everyone is secure by default.

  35. repeatable process

  36. Huh. $NEWEMPLOYEE, I'm not sure why $TOOL is acting this

    way for you. I think I set it up this way and I've never seen this before.
  37. Huh. $NEWEMPLOYEE, I'm not sure why $TOOLtool is acting this

    way for you. I think I set it up this way and I've never seen this before. lame
  38. manual processes are error prone

  39. human beings are error prone

  40. computers are error prone as we make them

  41. community

  42. we open-sourced Boxen on friday (pst) (5 days ago today)

  43. 107 closed pull requests + 17 open pull requests

  44. 198 closed issues + 43 open issues

  45. the community is interested in seeing Boxen improve

  46. GitHub is interested in seeing Boxen improve

  47. It's not abandon-ware

  48. We use the same modules

  49. boxen/our-boxen is extracted from GitHub's boxen and kept closely in

    sync
  50. stdlib

  51. Puppet has this thing called the Puppet Forge

  52. It's kinda like rubygems.org

  53. but imagine now you've got 10 gems trying to be

    bundler that ship the `bundle` command all fighting with one another about who's the best
  54. oh and random other libraries depend on specific implementations of

    that bundler- wannabe
  55. oh and random other libraries depend on specific implementations of

    that bundler- wannabe lame
  56. oh and random other libraries depend on specific implementations of

    that bundler- wannabe lame la m e lame lam la lame lame
  57. Boxen shipped with about 90 modules all designed to not

    get in the way
  58. you can roll your own, but we've already made it

    easy for you
  59. p.s. chef has a lot of the same problems with

    3rd party tooling too. it's not just a puppet thing.
  60. how does boxen work?

  61. puppet

  62. Puppet is a configuration management tool

  63. Puppet code says "I want my system to look like

    so"
  64. Running Puppet makes sure the system looks like so

  65. Every single time

  66. Idempotent

  67. puppet codez

  68. Resources

  69. package { 'git': } service { 'mysqld': } user {

    'wfarr': } exec { 'rm -rf /': }
  70. Types

  71. cron, exec, file, host, mount, package, service, ssh_authorized_key, user, vlan,

    zfs, and way more
  72. Providers

  73. package => aptget, pkgdmg, yum, etc service => init, systemd,

    upstart, etc
  74. package { 'git': ensure => '1.8.1', provider => 'aptget', }

  75. exec { 'rm -rf /': onlyif => '/bin/false', provider =>

    'shell' }
  76. Variables

  77. $somevar = "whatever"

  78. That's cool, chief. Let me try.

  79. $hostname = `hostname`

  80. $hostname = `hostname` nope

  81. Facter

  82. $::hostname #=> "scruffy" $::macosx_buildversion #=> "12C2034" $::osfamily #=> "Darwin" $::sp_l3_cache

    #=> "3 MB"
  83. Facter.add("root_encrypted") do def root_encrypted? system "/usr/sbin/diskutil", "coreStorage", "info", "/", ">

    /dev/null 2>&1" end setcode do root_encrypted? ? 'yes' : 'no' end end
  84. Classes

  85. class git { # some git stuff }

  86. class git::package { case $::operatingsystem { Debian: { package {

    'git-core': } } default: { package { 'git': } } } }
  87. class git { require apt include git::config include git::package }

  88. Relationships

  89. class mysql { package { 'mysql': } file { '/etc/my.cnf':

    mode => '0400', owner => 'mysql', } service { 'mysql': } }
  90. class mysql { package { 'mysql': } file { '/etc/my.cnf':

    mode => '0400', owner => 'mysql', } service { 'mysql': } } wrong
  91. class mysql { package { 'mysql': notify => Service['mysql'], }

    file { '/etc/my.cnf': mode => '0400', owner => 'mysql', notify => Service['mysql'], require => Package['mysql'], } service { 'mysql': } }
  92. Metaparameters

  93. notify/before subscribe/require

  94. Puppet is Declarative

  95. Puppet is not Procedural

  96. Use the DAG

  97. modules

  98. A lot like Ruby

  99. Puppet loads modules off the modulepath

  100. Modules have a certain directory layout

  101. . !"" files # $"" static_file !"" lib # !""

    facter # # $"" a_custom_fact.rb # $"" puppet # !"" parser # # $"" functions # # $"" a_custom_puppet_function.rb # !"" provider # # !"" repository # # # $"" git.rb # $"" type # $"" repository.rb !"" manifests # !"" config.pp # !"" init.pp $"" templates $"" some_template.erb
  102. puppetfile

  103. Bundler for Puppet

  104. # Puppetfile forge 'http://forge.puppetlabs.com/' mod 'boxen', \ :git => 'https://github.com/boxen/puppet-boxen.git'

    mod 'stdlib', '3.0.0'
  105. how do i get a boxen?

  106. Automate Everything

  107. boxen/boxen-web

  108. None
  109. how do i use my boxen?

  110. command line tool

  111. $ boxen # Run it

  112. $ boxen --projects # List projects Boxen knows about

  113. $ boxen <project name> # Sets up <project name>

  114. project manifests

  115. I want to hack on my project boxen-web

  116. # modules/projects/manifests/boxen- web.pp class projects::boxen-web { boxen::project { 'boxen-web': nginx

    => true, postgresql => true, ruby => '1.9.3', source => 'boxen/boxen-web' } }
  117. $ boxen boxen-web

  118. cloned repo nginx vhost ruby version postgres databases .env file

  119. $ cd ~/src/boxen-web $ script/server $ open http://boxen-web.dev/

  120. personal manifests

  121. I want to install $X but only for me

  122. # modules/people/manifests/wfarr.pp class people::wfarr { include minecraft }

  123. # modules/people/manifests/wfarr.pp class people::wfarr { include zsh }

  124. # modules/people/manifests/wfarr.pp class people::wfarr { case $::hostname { 'bender': {

    include projects::all } 'scruffy': { include projects::octostatus } default: {} } }
  125. # modules/people/manifests/wfarr.pp class people::wfarr { git::config::global { 'alias.st': value =>

    'status'; 'alias.ci': value => 'commit'; 'alias.co': value => 'checkout'; 'alias.di': value => 'diff'; 'alias.dc': value => 'diff --cached'; 'alias.lp': value => 'log -p'; 'color.ui': value => 'true'; 'user.name': value => 'Will Farrington'; 'user.email': value => 'wfarr@github.com'; } }
  126. # modules/people/manifests/wfarr.pp class people::wfarr { boxen::osx_defaults { 'fast key repeat':

    ensure => present, domain => 'NSGlobalDomain', key => 'KeyRepeat', value => 0, user => $::boxen_user; 'stop showing stupid popover': ensure => present, domain => 'NSGlobalDomain', key => 'ApplePressAndHoldEnabled', value => false, user => $::boxen_user; } }
  127. issues

  128. $ boxen Error: ZOMG at /opt/boxen/repo/ modules/people/manifests/wfarr.pp:8 on node scruffy.gateway.github.lan

    Sorry! Creating an issue on github/ totally-a-madeup-repo-name.
  129. CODEZ

  130. CODEZ who failed

  131. CODEZ how long ago

  132. CODEZ machine

  133. CODEZ os version

  134. CODEZ shell

  135. CODEZ ref

  136. CODEZ compare view

  137. CODEZ git status

  138. CODEZ full command

  139. CODEZ full log

  140. I'll fix the error and run `boxen`

  141. CODEZ

  142. GitHub Issues API

  143. # config/boxen.rb ENV['BOXEN_REPO_NAME'] = \ 'github/github-boxen' ENV['BOXEN_ISSUES_ENABLED'] = 'yes'

  144. auto-update

  145. $ boxen # auto-updates cleanly and runs

  146. $ boxen Boxen has a dirty tree, won't auto- update!

  147. $ boxen Boxen has unpushed commits on master, won't auto-update!

  148. $ boxen Boxen on a non-master branch 'new- project', won't

    auto-update!
  149. i'm sold.

  150. cool.

  151. get started.

  152. make a boxen for your company

  153. make a boxen for your community

  154. make a boxen for your thing that uses computers

  155. None
  156. what if i have problems?

  157. file issues on github

  158. irc.freenode.net

  159.  wfarr come work with me on things like boxen

  160. thanks

  161. speakerdeck.com/wfarr/boxen