Slide 1

Slide 1 text

BOXEN

Slide 2

Slide 2 text

 wfarr

Slide 3

Slide 3 text

 ops

Slide 4

Slide 4 text

 friction

Slide 5

Slide 5 text

what is a boxen?

Slide 6

Slide 6 text

Ruby Framework

Slide 7

Slide 7 text

@jbarnette + @wfarr

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Boxen is a framework

Slide 10

Slide 10 text

Boxen is a standard library

Slide 11

Slide 11 text

Boxen is a philosophy on how your machine should be configured

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

why should i use boxen?

Slide 14

Slide 14 text

shipping day one

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

constant updates

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Want to know how GitHub tested ruby 1.9.3 in development?

Slide 23

Slide 23 text

I pushed an update to Boxen.

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

security

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Now everyone is secure by default.

Slide 35

Slide 35 text

repeatable process

Slide 36

Slide 36 text

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.

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

manual processes are error prone

Slide 39

Slide 39 text

human beings are error prone

Slide 40

Slide 40 text

computers are error prone as we make them

Slide 41

Slide 41 text

community

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

107 closed pull requests + 17 open pull requests

Slide 44

Slide 44 text

198 closed issues + 43 open issues

Slide 45

Slide 45 text

the community is interested in seeing Boxen improve

Slide 46

Slide 46 text

GitHub is interested in seeing Boxen improve

Slide 47

Slide 47 text

It's not abandon-ware

Slide 48

Slide 48 text

We use the same modules

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

stdlib

Slide 51

Slide 51 text

Puppet has this thing called the Puppet Forge

Slide 52

Slide 52 text

It's kinda like rubygems.org

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

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

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

how does boxen work?

Slide 61

Slide 61 text

puppet

Slide 62

Slide 62 text

Puppet is a configuration management tool

Slide 63

Slide 63 text

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

Slide 64

Slide 64 text

Running Puppet makes sure the system looks like so

Slide 65

Slide 65 text

Every single time

Slide 66

Slide 66 text

Idempotent

Slide 67

Slide 67 text

puppet codez

Slide 68

Slide 68 text

Resources

Slide 69

Slide 69 text

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

Slide 70

Slide 70 text

Types

Slide 71

Slide 71 text

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

Slide 72

Slide 72 text

Providers

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

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

Slide 75

Slide 75 text

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

Slide 76

Slide 76 text

Variables

Slide 77

Slide 77 text

$somevar = "whatever"

Slide 78

Slide 78 text

That's cool, chief. Let me try.

Slide 79

Slide 79 text

$hostname = `hostname`

Slide 80

Slide 80 text

$hostname = `hostname` nope

Slide 81

Slide 81 text

Facter

Slide 82

Slide 82 text

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

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

Classes

Slide 85

Slide 85 text

class git { # some git stuff }

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

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

Slide 88

Slide 88 text

Relationships

Slide 89

Slide 89 text

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

Slide 90

Slide 90 text

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

Slide 91

Slide 91 text

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

Slide 92

Slide 92 text

Metaparameters

Slide 93

Slide 93 text

notify/before subscribe/require

Slide 94

Slide 94 text

Puppet is Declarative

Slide 95

Slide 95 text

Puppet is not Procedural

Slide 96

Slide 96 text

Use the DAG

Slide 97

Slide 97 text

modules

Slide 98

Slide 98 text

A lot like Ruby

Slide 99

Slide 99 text

Puppet loads modules off the modulepath

Slide 100

Slide 100 text

Modules have a certain directory layout

Slide 101

Slide 101 text

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

Slide 102

Slide 102 text

puppetfile

Slide 103

Slide 103 text

Bundler for Puppet

Slide 104

Slide 104 text

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

Slide 105

Slide 105 text

how do i get a boxen?

Slide 106

Slide 106 text

Automate Everything

Slide 107

Slide 107 text

boxen/boxen-web

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

how do i use my boxen?

Slide 110

Slide 110 text

command line tool

Slide 111

Slide 111 text

$ boxen # Run it

Slide 112

Slide 112 text

$ boxen --projects # List projects Boxen knows about

Slide 113

Slide 113 text

$ boxen # Sets up

Slide 114

Slide 114 text

project manifests

Slide 115

Slide 115 text

I want to hack on my project boxen-web

Slide 116

Slide 116 text

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

Slide 117

Slide 117 text

$ boxen boxen-web

Slide 118

Slide 118 text

cloned repo nginx vhost ruby version postgres databases .env file

Slide 119

Slide 119 text

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

Slide 120

Slide 120 text

personal manifests

Slide 121

Slide 121 text

I want to install $X but only for me

Slide 122

Slide 122 text

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

Slide 123

Slide 123 text

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

Slide 124

Slide 124 text

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

Slide 125

Slide 125 text

# 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]'; } }

Slide 126

Slide 126 text

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

Slide 127

Slide 127 text

issues

Slide 128

Slide 128 text

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

Slide 129

Slide 129 text

CODEZ

Slide 130

Slide 130 text

CODEZ who failed

Slide 131

Slide 131 text

CODEZ how long ago

Slide 132

Slide 132 text

CODEZ machine

Slide 133

Slide 133 text

CODEZ os version

Slide 134

Slide 134 text

CODEZ shell

Slide 135

Slide 135 text

CODEZ ref

Slide 136

Slide 136 text

CODEZ compare view

Slide 137

Slide 137 text

CODEZ git status

Slide 138

Slide 138 text

CODEZ full command

Slide 139

Slide 139 text

CODEZ full log

Slide 140

Slide 140 text

I'll fix the error and run `boxen`

Slide 141

Slide 141 text

CODEZ

Slide 142

Slide 142 text

GitHub Issues API

Slide 143

Slide 143 text

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

Slide 144

Slide 144 text

auto-update

Slide 145

Slide 145 text

$ boxen # auto-updates cleanly and runs

Slide 146

Slide 146 text

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

Slide 147

Slide 147 text

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

Slide 148

Slide 148 text

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

Slide 149

Slide 149 text

i'm sold.

Slide 150

Slide 150 text

cool.

Slide 151

Slide 151 text

get started.

Slide 152

Slide 152 text

make a boxen for your company

Slide 153

Slide 153 text

make a boxen for your community

Slide 154

Slide 154 text

make a boxen for your thing that uses computers

Slide 155

Slide 155 text

No content

Slide 156

Slide 156 text

what if i have problems?

Slide 157

Slide 157 text

file issues on github

Slide 158

Slide 158 text

irc.freenode.net

Slide 159

Slide 159 text

 wfarr come work with me on things like boxen

Slide 160

Slide 160 text

thanks

Slide 161

Slide 161 text

speakerdeck.com/wfarr/boxen