$30 off During Our Annual Pro Sale. View Details »

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.

Will Farrington

February 21, 2013
Tweet

More Decks by Will Farrington

Other Decks in Technology

Transcript

  1. BOXEN

    View Slide


  2. wfarr

    View Slide


  3. ops

    View Slide


  4. friction

    View Slide

  5. what is a boxen?

    View Slide

  6. Ruby Framework

    View Slide

  7. @jbarnette + @wfarr

    View Slide

  8. when two developers get really
    angry at how awful a bunch of
    things are, they write code

    View Slide

  9. Boxen is a
    framework

    View Slide

  10. Boxen is a
    standard library

    View Slide

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

    View Slide

  12. Boxen tries to make
    installing system
    dependencies,
    configuring your machine,
    and generally everything
    easier and automated

    View Slide

  13. why should i use
    boxen?

    View Slide

  14. shipping day one

    View Slide

  15. It's my first day at company X.
    So excited to work on $THING!

    View Slide

  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

    View Slide

  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

    View Slide

  18. 1. open boxen-web
    2. run the command
    3. ship code

    View Slide

  19. constant updates

    View Slide

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

    View Slide

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

    View Slide

  22. Want to know how GitHub tested
    ruby 1.9.3 in development?

    View Slide

  23. I pushed an update to Boxen.

    View Slide

  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."

    View Slide

  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

    View Slide

  26. If you make updating hard,
    people won't update.

    View Slide

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

    View Slide

  28. If you lack consistency in
    development and production,
    you're going to have a bad time.

    View Slide

  29. security

    View Slide

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

    View Slide

  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

    View Slide

  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

    View Slide

  33. View Slide

  34. Now everyone is secure by default.

    View Slide

  35. repeatable process

    View Slide

  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.

    View Slide

  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

    View Slide

  38. manual processes
    are error prone

    View Slide

  39. human beings
    are error prone

    View Slide

  40. computers
    are error prone as we make them

    View Slide

  41. community

    View Slide

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

    View Slide

  43. 107 closed pull requests +
    17 open pull requests

    View Slide

  44. 198 closed issues +
    43 open issues

    View Slide

  45. the community
    is interested in seeing Boxen
    improve

    View Slide

  46. GitHub
    is interested in seeing Boxen
    improve

    View Slide

  47. It's not abandon-ware

    View Slide

  48. We use the same modules

    View Slide

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

    View Slide

  50. stdlib

    View Slide

  51. Puppet has this thing called the
    Puppet Forge

    View Slide

  52. It's kinda like rubygems.org

    View Slide

  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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  57. Boxen shipped with about 90
    modules all designed to not get in
    the way

    View Slide

  58. you can roll your own, but we've
    already made it easy for you

    View Slide

  59. p.s. chef has a lot of the same
    problems with 3rd party tooling
    too. it's not just a puppet thing.

    View Slide

  60. how does boxen
    work?

    View Slide

  61. puppet

    View Slide

  62. Puppet is a configuration
    management tool

    View Slide

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

    View Slide

  64. Running Puppet
    makes sure the system looks like so

    View Slide

  65. Every single time

    View Slide

  66. Idempotent

    View Slide

  67. puppet codez

    View Slide

  68. Resources

    View Slide

  69. package { 'git': }
    service { 'mysqld': }
    user { 'wfarr': }
    exec { 'rm -rf /': }

    View Slide

  70. Types

    View Slide

  71. cron, exec, file, host, mount,
    package, service, ssh_authorized_key,
    user, vlan, zfs, and way more

    View Slide

  72. Providers

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  76. Variables

    View Slide

  77. $somevar = "whatever"

    View Slide

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

    View Slide

  79. $hostname = `hostname`

    View Slide

  80. $hostname = `hostname`
    nope

    View Slide

  81. Facter

    View Slide

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

    View Slide

  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

    View Slide

  84. Classes

    View Slide

  85. class git {
    # some git stuff
    }

    View Slide

  86. class git::package {
    case $::operatingsystem {
    Debian: {
    package { 'git-core': }
    }
    default: {
    package { 'git': }
    }
    }
    }

    View Slide

  87. class git {
    require apt
    include git::config
    include git::package
    }

    View Slide

  88. Relationships

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  92. Metaparameters

    View Slide

  93. notify/before
    subscribe/require

    View Slide

  94. Puppet is Declarative

    View Slide

  95. Puppet is not Procedural

    View Slide

  96. Use the DAG

    View Slide

  97. modules

    View Slide

  98. A lot like Ruby

    View Slide

  99. Puppet loads modules off the
    modulepath

    View Slide

  100. Modules have a certain
    directory layout

    View Slide

  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

    View Slide

  102. puppetfile

    View Slide

  103. Bundler for Puppet

    View Slide

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

    View Slide

  105. how do i get a
    boxen?

    View Slide

  106. Automate Everything

    View Slide

  107. boxen/boxen-web

    View Slide

  108. View Slide

  109. how do i use my
    boxen?

    View Slide

  110. command line tool

    View Slide

  111. $ boxen
    # Run it

    View Slide

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

    View Slide

  113. $ boxen
    # Sets up

    View Slide

  114. project manifests

    View Slide

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

    View Slide

  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'
    }
    }

    View Slide

  117. $ boxen boxen-web

    View Slide

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

    View Slide

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

    View Slide

  120. personal manifests

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  124. # modules/people/manifests/wfarr.pp
    class people::wfarr {
    case $::hostname {
    'bender': {
    include projects::all
    }
    'scruffy': {
    include projects::octostatus
    }
    default: {}
    }
    }

    View Slide

  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 => '[email protected]';
    }
    }

    View Slide

  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;
    }
    }

    View Slide

  127. issues

    View Slide

  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.

    View Slide

  129. CODEZ

    View Slide

  130. CODEZ
    who failed

    View Slide

  131. CODEZ
    how long ago

    View Slide

  132. CODEZ machine

    View Slide

  133. CODEZ
    os version

    View Slide

  134. CODEZ shell

    View Slide

  135. CODEZ
    ref

    View Slide

  136. CODEZ
    compare view

    View Slide

  137. CODEZ
    git status

    View Slide

  138. CODEZ
    full command

    View Slide

  139. CODEZ
    full log

    View Slide

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

    View Slide

  141. CODEZ

    View Slide

  142. GitHub Issues API

    View Slide

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

    View Slide

  144. auto-update

    View Slide

  145. $ boxen
    # auto-updates cleanly and runs

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  149. i'm sold.

    View Slide

  150. cool.

    View Slide

  151. get started.

    View Slide

  152. make a boxen for your
    company

    View Slide

  153. make a boxen for your
    community

    View Slide

  154. make a boxen for your
    thing that uses
    computers

    View Slide

  155. View Slide

  156. what if i have
    problems?

    View Slide

  157. file issues on github

    View Slide

  158. irc.freenode.net

    View Slide


  159. wfarr
    come work with me on
    things like boxen

    View Slide

  160. thanks

    View Slide

  161. speakerdeck.com/wfarr/boxen

    View Slide