Slide 1

Slide 1 text

Using Ruby to Automate your LIFE

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

REPETITIVE CAN OF SHIT

Slide 4

Slide 4 text

REPETITIVE CAN OF SHIT cap deploy git push irb ruby bundle rake guard rspec vagrant time

Slide 5

Slide 5 text

REPETITIVE CAN OF SHIT cap deploy git push tail /var/log ssh irb ruby ls bundle test rake heroku guard export rspec brew thor curl vagrant nano cut time

Slide 6

Slide 6 text

REPETITIVE CAN OF SHIT cap deploy apt-get install git clone git push cd directory tail /var/log top ssh irb ruby alias ls grep bundle test rake heroku gunzip guard head ping export cp rspec brew open thor telnet man chmod curl port vagrant chown vi packer nano cut find time hash COMMAND ALL THE THINGS!

Slide 7

Slide 7 text

REPETITIVE CAN OF SHIT cap deploy apt-get install git clone git push cd directory tail /var/log top ssh irb ruby alias ls grep bundle test rake heroku gunzip guard head ping export cp rspec brew open thor telnet man chmod curl port vagrant chown vi packer nano cut find time hash COMMAND ALL THE THINGS!

Slide 8

Slide 8 text

?

Slide 9

Slide 9 text

? REPRODUCIBLE

Slide 10

Slide 10 text

? REPRODUCIBLE RELIABLE

Slide 11

Slide 11 text

? REPRODUCIBLE RELIABLE UNTENDED

Slide 12

Slide 12 text

Slide 13

Slide 13 text

EVEN THOUGH I WORK FOR OPSCODE, THIS IS NOT A VENDOR PITCH. THE CHEF CLIENT IS COMPLETELY FREE AND OPEN SOURCED UNDER THE APACHE 2.0 LICENSE. DISCLAIMER #1

Slide 14

Slide 14 text

CHEF IS CROSS-PLATFORM BUT THESE EXAMPLES ASSUME A SINGLE PLATFORM FOR SIMPLICITY. DISCLAIMER #2

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

WHAT IS ? ? ? ? ?

Slide 17

Slide 17 text

CHEF IS... CONFIGURATION MANAGEMENT

Slide 18

Slide 18 text

CHEF IS... CLOUD ADMINISTRATION

Slide 19

Slide 19 text

CHEF IS... CONTINUOUS DELIVERY

Slide 20

Slide 20 text

CHEF IS... COMMUNITY-DRIVEN

Slide 21

Slide 21 text

CHEF IS... OPEN SOURCE

Slide 22

Slide 22 text

CHEF IS... CUSTOMER-FOCUSED

Slide 23

Slide 23 text

STUFF

Slide 24

Slide 24 text

STUFF LIKE

Slide 25

Slide 25 text

STUFF LIKE PROVISION

Slide 26

Slide 26 text

STUFF LIKE PROVISION DEVELOPER LAPTOPS

Slide 27

Slide 27 text

STUFF LIKE PROVISION DEVELOPER LAPTOPS AND REPLICATE YOUR EXACT

Slide 28

Slide 28 text

STUFF LIKE PROVISION DEVELOPER LAPTOPS AND REPLICATE PRODUCTION INFRASTRUCTURE YOUR EXACT

Slide 29

Slide 29 text

STUFF LIKE PROVISION DEVELOPER LAPTOPS AND REPLICATE PRODUCTION INFRASTRUCTURE YOUR EXACT

Slide 30

Slide 30 text

STUFF LIKE

Slide 31

Slide 31 text

STUFF LIKE MAINTAIN

Slide 32

Slide 32 text

STUFF LIKE MAINTAIN EPHEMERAL STAGING ENVIRONMENTS

Slide 33

Slide 33 text

STUFF LIKE MAINTAIN EPHEMERAL STAGING ENVIRONMENTS

Slide 34

Slide 34 text

STUFF LIKE

Slide 35

Slide 35 text

STUFF LIKE SPIN UP A COMPLETELY

Slide 36

Slide 36 text

STUFF LIKE SPIN UP A COMPLETELY NEW INFRASTRUCTURE

Slide 37

Slide 37 text

STUFF LIKE SPIN UP A COMPLETELY NEW INFRASTRUCTURE

Slide 38

Slide 38 text

Scenario #1

Slide 39

Slide 39 text

Scenario #1

Slide 40

Slide 40 text

[deploy_to] [deploy_to]/releases [deploy_to]/shared [deploy_to]/shared/log [deploy_to]/shared/pids [deploy_to]/shared/system $ cap deploy:setup

Slide 41

Slide 41 text

deploy_to = '/var/www/myface' directories = [ 'releases', 'shared', 'shared/log', 'shared/pids', 'shared/system', ] # Create each directory directories.each do |path| directory "#{deploy_to}/#{path}" end

Slide 42

Slide 42 text

directory 'path' do end DECLARE A DIRECTORY RESOURCE

Slide 43

Slide 43 text

directory 'path' do owner 'www-data' end SET THE DIRECTORY OWNER

Slide 44

Slide 44 text

directory 'path' do owner 'www-data' group 'www-data' end SET THE DIRECTORY GROUP

Slide 45

Slide 45 text

directory 'path' do owner 'www-data' group 'www-data' mode '0755' end SET THE DIRECTORY PERMISSIONS

Slide 46

Slide 46 text

[checkout latest ref] current -> releases/20134567890 [update pid files] $ cap deploy

Slide 47

Slide 47 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 48

Slide 48 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 49

Slide 49 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 50

Slide 50 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 51

Slide 51 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 52

Slide 52 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 53

Slide 53 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 54

Slide 54 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 55

Slide 55 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 56

Slide 56 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 57

Slide 57 text

timestamp = Time.now.to_i git "#{deploy_to}/#{timestamp}" do repository 'git://github.com/user/repo.git reference 'master' depth 1 action :checkout end link "#{deploy_to}/current" do to "#{deploy_to}/#{timestamp}" end file "#{deploy_to}/current/tmp/restart.txt" do action :touch end

Slide 58

Slide 58 text

Idempotency

Slide 59

Slide 59 text

Security

Slide 60

Slide 60 text

service chef-client

Slide 61

Slide 61 text

cap deploy git push

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Scenario #2

Slide 64

Slide 64 text

Scenario #2

Slide 65

Slide 65 text

New Laptop

Slide 66

Slide 66 text

New Laptop vagrant git Google Chrome VirtualBox

Slide 67

Slide 67 text

New Laptop redis vagrant mongodb sqlite postgresql mysql git Google Chrome VirtualBox

Slide 68

Slide 68 text

New Laptop redis vagrant mongodb sqlite postgresql rbenv mysql git ruby-build Google Chrome VirtualBox

Slide 69

Slide 69 text

New Laptop redis vagrant mongodb sqlite postgresql rbenv mysql imagemagick git graphviz gecode ruby-build Google Chrome Firefox VirtualBox

Slide 70

Slide 70 text

New Laptop OPEN UP SAFARI SAFARI AND THE SAFARI LOGO COPYRIGHT APPLE, INC

Slide 71

Slide 71 text

New Laptop NAVIGATE TO CHROME'S WEBSITE GOOGLE CHOME AND THE CHROME LOGO COPYRIGHT GOOGLE, INC.

Slide 72

Slide 72 text

New Laptop DOWNLOAD CHROME GOOGLE CHOME AND THE CHROME LOGO COPYRIGHT GOOGLE, INC.

Slide 73

Slide 73 text

New Laptop DRAG CHROME INTO THE APPLICATIONS DIRECTORY GOOGLE CHOME AND THE CHROME LOGO COPYRIGHT GOOGLE, INC.

Slide 74

Slide 74 text

New Laptop dmg_package 'Google Chrome' do dmg_name 'googlechrome' source 'https://dl-ssl.google.com...' end

Slide 75

Slide 75 text

New Laptop dmg_package 'Google Chrome' do dmg_name 'googlechrome' source 'https://dl-ssl.google.com...' end SIMPLE

Slide 76

Slide 76 text

New Laptop dmg_package 'Google Chrome' do dmg_name 'googlechrome' source 'https://dl-ssl.google.com...' end FAST

Slide 77

Slide 77 text

New Laptop dmg_package 'Google Chrome' do dmg_name 'googlechrome' source 'https://dl-ssl.google.com...' end REPRODUCIBLE

Slide 78

Slide 78 text

New Laptop dmg_package 'Mozilla Firefox' do dmg_name 'firefox' source 'https://download.mozilla.org/...' end BAM! FIREFOX TOO

Slide 79

Slide 79 text

New Laptop dmg_package 'Virtual Box' do dmg_name 'virtualbox' source 'http://download.virtualbox.org/...' end dmg_package 'Vagrant' do dmg_name 'vagrant' source 'http://files.vagrantup.com/...' end VIRTUALBOX & VAGRANT

Slide 80

Slide 80 text

New Laptop %w[ gecode git graphviz imagemagick mongodb mysql postgresql rbenv redis ruby-build sqlite ].each do |name| homebrew_package name end PACKAGES? NO PROBLEM!

Slide 81

Slide 81 text

New Laptop %w[ gecode git graphviz imagemagick mongodb mysql postgresql rbenv redis ruby-build sqlite ].each do |name| homebrew_package name end WANT SOME RUBIES? rbenv ruby-build

Slide 82

Slide 82 text

New Laptop %w[ 1.8.7-p371 1.9.3-p448 2.0.0-p247 ].each do |version| execute "rbenv install #{version}" do not_if "rbenv versions | grep #{version}" end end INSTALL SOME RUBIES

Slide 83

Slide 83 text

New Laptop %w[ 1.8.7-p371 1.9.3-p448 2.0.0-p247 ].each do |version| execute "rbenv install #{version}" do not_if "rbenv versions | grep #{version}" end end IDEMPOTENCY not_if "rbenv versions | grep #{version}"

Slide 84

Slide 84 text

New Laptop def set_background(file) """ tell application "Finder" set desktop picture to POSIX file "#{file}" end tell killall Dock """ end SET THE DESKTOP BACKGROUND

Slide 85

Slide 85 text

New Laptop def set_background(file) """ tell application "Finder" set desktop picture to POSIX file "#{file}" end tell killall Dock """ end SET THE DESKTOP BACKGROUND ?

Slide 86

Slide 86 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND

Slide 87

Slide 87 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND image = '/Library/Cache/my_background.png'

Slide 88

Slide 88 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND remote_file image do

Slide 89

Slide 89 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND source 'http://imgur.com/a/5hbCH'

Slide 90

Slide 90 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND action :create_if_missing

Slide 91

Slide 91 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND notifies :run, 'execute[set desktop background]'

Slide 92

Slide 92 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND execute 'set desktop background' do

Slide 93

Slide 93 text

New Laptop image = '/Library/Cache/my_background.png' remote_file image do source 'http://imgur.com/a/5hbCH' action :create_if_missing notifies :run, 'execute[set desktop background]' end execute 'set desktop background' do command "oascript #{set_background(image)}" action :nothing end SET THE DESKTOP BACKGROUND command "oascript #{set_background(image)}"

Slide 94

Slide 94 text

INSTALLED

Slide 95

Slide 95 text

INSTALLED Google Chrome Firefox Virtual Box Vagrant MongoDB PostgreSQL Rbenv

Slide 96

Slide 96 text

INSTALLED Google Chrome Firefox CONFIGURED Virtual Box Vagrant MongoDB PostgreSQL Rbenv

Slide 97

Slide 97 text

INSTALLED Google Chrome Firefox CONFIGURED Virtual Box Vagrant MongoDB PostgreSQL Rbenv Gecode Graphviz 3 Rubies Desktop Background

Slide 98

Slide 98 text

INSTALLED Google Chrome Firefox CONFIGURED Virtual Box Vagrant MongoDB PostgreSQL Rbenv Gecode Graphviz 3 Rubies Desktop Background lines of code

Slide 99

Slide 99 text

INSTALLED Google Chrome Firefox CONFIGURED Virtual Box Vagrant MongoDB PostgreSQL Rbenv Gecode Graphviz 3 Rubies Desktop Background < 150 lines of code

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

I KNOW WHAT YOU'RE THINKING

Slide 102

Slide 102 text

I KNOW WHAT YOU'RE THINKING HOW IS THIS BETTER THAN A BASH SCRIPT?

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

RELIABLE

Slide 105

Slide 105 text

RELIABLE REPRODUCIBLE

Slide 106

Slide 106 text

RELIABLE REPRODUCIBLE IDEMPOTENT

Slide 107

Slide 107 text

RELIABLE REPRODUCIBLE CROSS-PLATFORM IDEMPOTENT

Slide 108

Slide 108 text

RELIABLE REPRODUCIBLE CROSS-PLATFORM CLEAN IDEMPOTENT

Slide 109

Slide 109 text

RELIABLE REPRODUCIBLE CROSS-PLATFORM CLEAN IDEMPOTENT RUBY

Slide 110

Slide 110 text

RELIABLE REPRODUCIBLE CROSS-PLATFORM CLEAN IT'S NOT BASH IDEMPOTENT RUBY

Slide 111

Slide 111 text

RELIABLE REPRODUCIBLE CROSS-PLATFORM CLEAN IT'S NOT BASH IDEMPOTENT RUBY

Slide 112

Slide 112 text

I KNOW WHAT YOU'RE THINKING

Slide 113

Slide 113 text

I KNOW WHAT YOU'RE THINKING I WANT IT NOW!

Slide 114

Slide 114 text

getchef.opscode.com GET CHEF

Slide 115

Slide 115 text

learnchef.opscode.com LEARN CHEF

Slide 116

Slide 116 text

opscode.com/blog/careers BE CHEF

Slide 117

Slide 117 text

! https://github.com/sethvargo @sethvargo +sethvargo Questions?