Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
BROWN BAG:
Rapid Chef
Development

Hart Hoover
@hhoover

CLOUD SAVVY
CLOUD SAVVY

2
ENTERPRISE

CLOUD SAVVY

3
CHEF SOLO

CLOUD SAVVY

4
OPEN SOURCE CHEF
CLOUD SAVVY

5
TOOLS!

CLOUD SAVVY

6
TOOLS!

• Git/GitHub

CLOUD SAVVY

6
TOOLS!

• Git/GitHub
• Berkshelf

CLOUD SAVVY

6
TOOLS!

• Git/GitHub
• Berkshelf
• Vagrant

CLOUD SAVVY

6
TOOLS!

•
•
•
•

CLOUD SAVVY

Git/GitHub
Berkshelf
Vagrant
Vagrant Plugins

6
TOOLS!

•
•
•
•
•

CLOUD SAVVY

Git/GitHub
Berkshelf
Vagrant
Vagrant Plugins
Test Kitchen

6
TOOLS!

•
•
•
•
•
•

CLOUD SAVVY

Git/GitHub
Berkshelf
Vagrant
Vagrant Plugins
Test Kitchen
Foodcritic

6
CLOUD SAVVY

7
CLOUD SAVVY

8
CLOUD SAVVY

8
CLOUD SAVVY

8
• A CLI Tool
• A Source Code Management Tool
• A Package Manager
• Replaces parts of knife
• Specifically cookbook managem...
• A CLI Tool
• A Source Code Management Tool
• A Package Manager
• Replaces parts of knife
• Specifically cookbook managem...
CLOUD SAVVY

9
CLOUD SAVVY

10
Why Vagrant?
Developers

• Repeatable
• Customizable
• “It works on my machine.”

CLOUD SAVVY

11
Why Vagrant?
Operations

• Disposable Machines
• Test your provisioning
• Local → Production

CLOUD SAVVY

12
Why Vagrant?

=

CLOUD SAVVY

13
TEST KITCHEN

Convergence
Integration Testing
for Chef

CLOUD SAVVY

14
TEST KITCHEN

Convergence
Integration Testing
for Chef
Does my cookbook work?

CLOUD SAVVY

14
TEST KITCHEN
NO

Convergence
Integration Testing
for Chef
Does my cookbook work?

CLOUD SAVVY

14
FoodCritic
Lint testing!
Makes it easy to flag
known issues
Better Cookbooks!
CLOUD SAVVY

15
Chef
WorkFlowS

CLOUD SAVVY
OLD CHEF DEV WORKFLOW

CLOUD SAVVY

17
OLD CHEF DEV WORKFLOW
Edit
Cookbook

CLOUD SAVVY

17
OLD CHEF DEV WORKFLOW
Edit
Cookbook
Upload
Cookbook

CLOUD SAVVY

17
OLD CHEF DEV WORKFLOW
Edit
Cookbook
Upload
Cookbook

Provision
Machine

CLOUD SAVVY

17
OLD CHEF DEV WORKFLOW
Edit
Cookbook
Upload
Cookbook

Provision
Machine
Bootstrap
Machine
CLOUD SAVVY

17
OLD CHEF DEV WORKFLOW
Edit
Cookbook
Upload
Cookbook

Run
Chef Client

Provision
Machine
Bootstrap
Machine
CLOUD SAVVY

17
OLD CHEF DEV WORKFLOW
Edit
Cookbook
SSH &
Validate

Upload
Cookbook

Run
Chef Client

Provision
Machine
Bootstrap
Machine
...
OLD CHEF DEV WORKFLOW
Edit
Cookbook
SSH &
Validate

Upload
Cookbook

Run
Chef Client

Provision
Machine
Bootstrap
Machine
...
NEW CHEF DEV WORKFLOW

Edit
Cookbook

Test
Kitchen

Vagrant
Up

CLOUD SAVVY

18
Our Workflow

Berkshelf

Vagrant
Up

Test
Kitchen

GitHub

CLOUD SAVVY

Production

Monitoring

19
Our Workflow

Berkshelf

Vagrant
Up

Test
Kitchen

GitHub

CLOUD SAVVY

Production

Monitoring

19
Our Workflow

{

DEV

Berkshelf

Vagrant
Up

Test
Kitchen

GitHub

CLOUD SAVVY

Production

Monitoring

19
Our Workflow

OPS

{

{

DEV

Berkshelf

Vagrant
Up

Test
Kitchen

GitHub

CLOUD SAVVY

Production

Monitoring

19
Development
Walkthrough
Prerequisites

CLOUD SAVVY
What You need

•
•
•
•
•
•
•

VirtualBox
Vagrant
Opscode’s 12.04 Vagrant Box
Ruby (1.9.3 or higher!)
Berkshelf
Test Kitche...
Virtualbox

https://www.virtualbox.org/wiki/Downloads

CLOUD SAVVY

22
Vagrant

http://downloads.vagrantup.com

CLOUD SAVVY

23
OPSCODE’S VAGRANT BOX

$	
  vagrant	
  box	
  add	
  
opscode-­‐ubuntu-­‐12.04	
  
http://tinyurl.com/chef1204	
  

CLOUD ...
CREATE A PROJECT

$	
  mkdir	
  -­‐p	
  ~/projects/chefnovaclient
$	
  cd	
  ~/projects/chefnovaclient

CLOUD SAVVY

25
Berkshelf

$	
  gem	
  install	
  berkshelf

CLOUD SAVVY

26
Test Kitchen

$	
  gem	
  install	
  test-­‐kitchen	
  -­‐-­‐pre

CLOUD SAVVY

27
FoodCritic

$	
  gem	
  install	
  foodcritic

CLOUD SAVVY

28
CLOUD SAVVY

29
Development
Walkthrough

rackspace-novaclient
&
supernova

CLOUD SAVVY
GET STARTED

$	
  cd	
  ~/projects/chefnovaclient
$	
  berks	
  init

CLOUD SAVVY

31
$	
  berks	
  init
berks	
  init
	
  	
  	
  	
  	
  	
  create	
  	
  Berksfile
	
  	
  	
  	
  	
  	
  create	
  	
  Tho...
$	
  berks	
  init
berks	
  init
	
  	
  	
  	
  	
  	
  create	
  	
  Berksfile
	
  	
  	
  	
  	
  	
  create	
  	
  Tho...
$	
  berks	
  init
berks	
  init
	
  	
  	
  	
  	
  	
  create	
  	
  Berksfile
	
  	
  	
  	
  	
  	
  create	
  	
  Tho...
$	
  berks	
  init
berks	
  init
	
  	
  	
  	
  	
  	
  create	
  	
  Berksfile
	
  	
  	
  	
  	
  	
  create	
  	
  Tho...
$	
  berks	
  init
berks	
  init
	
  	
  	
  	
  	
  	
  create	
  	
  Berksfile
	
  	
  	
  	
  	
  	
  create	
  	
  Tho...
$	
  berks	
  init
berks	
  init
	
  	
  	
  	
  	
  	
  create	
  	
  Berksfile
	
  	
  	
  	
  	
  	
  create	
  	
  Tho...
$	
  berks	
  init
berks	
  init
	
  	
  	
  	
  	
  	
  create	
  	
  Berksfile
	
  	
  	
  	
  	
  	
  create	
  	
  Tho...
CLOUD SAVVY

39
INSTALL Kitchen-Vagrant

$	
  gem	
  install	
  kitchen-­‐vagrant

CLOUD SAVVY

40
SET UP TEST KITCHEN
Goodbye
10.04!

CLOUD SAVVY

41
RUN Test KitchEN

$	
  kitchen	
  verify

Good Luck!
CLOUD SAVVY

42
CLOUD SAVVY

43
WHAT FAILED?

FATAL:	
  No	
  cookbook	
  found

CLOUD SAVVY

44
What are our
requirements?

CLOUD SAVVY

45
What are our
requirements?

Python
pip

make
package manager

setuptools
CLOUD SAVVY

45
COPY/PasTE

http://tinyurl.com/chefpart2

CLOUD SAVVY

46
BERKSFILE:
DependencIES!

site	
  :opscode
cookbook	
  'apt'
cookbook	
  'build-­‐essential'
cookbook	
  'python'
CLOUD SA...
RUN Test KitchEN

$	
  kitchen	
  converge

Good Luck!
CLOUD SAVVY

48
Congrats!

You installed something...

CLOUD SAVVY

49
Congrats!

You installed something...
but not what we need.

CLOUD SAVVY

49
BERKSFILE:
THIS IS A COOKBOOK

site	
  :opscode
cookbook	
  'apt'
cookbook	
  'build-­‐essential'
cookbook	
  'python'
met...
BERKSFILE:
THIS IS A COOKBOOK

site	
  :opscode
cookbook	
  'apt'
cookbook	
  'build-­‐essential'
cookbook	
  'python'
met...
RUN Test KitchEN

$	
  kitchen	
  converge

Good Luck!
CLOUD SAVVY

52
CLOUD SAVVY

53
WHAT FAILED?

Failed	
  to	
  complete	
  #converge	
  action

CLOUD SAVVY

54
metadata.RB:
What is this THING??
name	
  "chefnovaclient"
version	
  "1.0.0"
description	
  "Installs	
  the	
  novaclien...
RUN Test KitchEN

$	
  kitchen	
  converge

Good Luck!
CLOUD SAVVY

56
Congrats!

You installed something...

CLOUD SAVVY

57
Congrats!

You installed something...
but STILL not what we need.

CLOUD SAVVY

57
TIME TO WRITE RECIPES

CLOUD SAVVY

58
TIME TO WRITE RECIPES

$	
  berks	
  cookbook	
  .
Don’t overwrite stuff

CLOUD SAVVY

59
Default RECIPE:
recipes/default.rb
include_recipe	
  "apt"
include_recipe	
  "python::pip"
%w{git	
  python-­‐dev	
  build...
Default RECIPE:
recipes/default.rb
include_recipe	
  "apt"
include_recipe	
  "python::pip"
%w{git	
  python-­‐dev	
  build...
Default RECIPE:
recipes/default.rb
include_recipe	
  "apt"
include_recipe	
  "python::pip"
%w{git	
  python-­‐dev	
  build...
Default RECIPE:
recipes/default.rb
include_recipe	
  "apt"
include_recipe	
  "python::pip"
%w{git	
  python-­‐dev	
  build...
EDIT YOUR RUN LIST

.kitchen.yaml

suites:
-­‐	
  name:	
  default
	
  	
  run_list:
	
  	
  	
  	
  -­‐	
  recipe[chefnov...
EDIT YOUR RUN LIST

.kitchen.yaml

suites:
-­‐	
  name:	
  default
	
  	
  run_list:
	
  	
  	
  	
  -­‐	
  recipe[chefnov...
RUN FOODCRITIC!

$	
  foodcritic	
  .
Everything good?
CLOUD SAVVY

66
If Not:
FIX IT!

CLOUD SAVVY

67
RUN Test KitchEN

$	
  kitchen	
  converge

Good Luck!
CLOUD SAVVY

68
Did it work?

$	
  kitchen	
  login	
  default
$	
  nova	
  help

CLOUD SAVVY

69
CLOUD SAVVY

70
CLOUD SAVVY

71
SUPERNOVA

CLOUD SAVVY

72
Let’s MAKE
AUTOMATED TESTs

$	
  mkdir	
  test/integration/default/bats
$	
  touch	
  test/integration/default/bats/supern...
TESTING
test/integration/default/bats/supernova.bats

#!/usr/bin/env	
  bats
@test	
  "supernova	
  is	
  installed"	
  {
...
TESTING
test/integration/default/bats/supernova.bats

@test	
  "supernova	
  config	
  exists"	
  {
	
  	
  cat	
  /home/v...
TESTING
test/integration/default/bats/supernova.bats

@test	
  "run	
  supernova"	
  {
	
  	
  supernova	
  myaccount	
  l...
TESTING
test/integration/default/bats/supernova.bats

@test	
  "novaclient	
  installed"	
  {
	
  	
  which	
  nova
}
CLOU...
SUPERNOVA
recipes/default.rb
python_pip	
  "git+git://github.com/major/supernova.git"	
  do
	
   action	
  :install
end
te...
SuperNova
templates/default/supernova.erb
[myaccount]
OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/
OS_VERSION...
SuperNova
templates/default/supernova.erb
[myaccount]
OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/
OS_VERSION...
SuperNova
attributes/default.rb

default['chefnovaclient']['username']	
  =	
  "USERNAME"
default['chefnovaclient']['passw...
RUN FOODCRITIC!

$	
  foodcritic	
  .
Everything good?
CLOUD SAVVY

82
RUN Test KitchEN

$	
  kitchen	
  converge

Good Luck!
CLOUD SAVVY

83
RUN YOUR Tests

$	
  kitchen	
  verify

Good Luck!
CLOUD SAVVY

84
“SAVE YOUR WORK”

CLOUD SAVVY

85
THANK
YOU!

CLOUD SAVVY
Upcoming SlideShare
Loading in …5
×

Rapid Chef Development with Berkshelf, Test-Kitchen and Foodcritic

3,994 views

Published on

An introduction to Chef Cookbook development tools:
* Berkshelf
* Test-Kitchen
* Foodcritic

  • Be the first to comment

Rapid Chef Development with Berkshelf, Test-Kitchen and Foodcritic

  1. 1. BROWN BAG: Rapid Chef Development Hart Hoover @hhoover CLOUD SAVVY
  2. 2. CLOUD SAVVY 2
  3. 3. ENTERPRISE CLOUD SAVVY 3
  4. 4. CHEF SOLO CLOUD SAVVY 4
  5. 5. OPEN SOURCE CHEF CLOUD SAVVY 5
  6. 6. TOOLS! CLOUD SAVVY 6
  7. 7. TOOLS! • Git/GitHub CLOUD SAVVY 6
  8. 8. TOOLS! • Git/GitHub • Berkshelf CLOUD SAVVY 6
  9. 9. TOOLS! • Git/GitHub • Berkshelf • Vagrant CLOUD SAVVY 6
  10. 10. TOOLS! • • • • CLOUD SAVVY Git/GitHub Berkshelf Vagrant Vagrant Plugins 6
  11. 11. TOOLS! • • • • • CLOUD SAVVY Git/GitHub Berkshelf Vagrant Vagrant Plugins Test Kitchen 6
  12. 12. TOOLS! • • • • • • CLOUD SAVVY Git/GitHub Berkshelf Vagrant Vagrant Plugins Test Kitchen Foodcritic 6
  13. 13. CLOUD SAVVY 7
  14. 14. CLOUD SAVVY 8
  15. 15. CLOUD SAVVY 8
  16. 16. CLOUD SAVVY 8
  17. 17. • A CLI Tool • A Source Code Management Tool • A Package Manager • Replaces parts of knife • Specifically cookbook management CLOUD SAVVY 8
  18. 18. • A CLI Tool • A Source Code Management Tool • A Package Manager • Replaces parts of knife • Specifically cookbook management THE BERKSHELF WAY IS BETTER CLOUD SAVVY 8
  19. 19. CLOUD SAVVY 9
  20. 20. CLOUD SAVVY 10
  21. 21. Why Vagrant? Developers • Repeatable • Customizable • “It works on my machine.” CLOUD SAVVY 11
  22. 22. Why Vagrant? Operations • Disposable Machines • Test your provisioning • Local → Production CLOUD SAVVY 12
  23. 23. Why Vagrant? = CLOUD SAVVY 13
  24. 24. TEST KITCHEN Convergence Integration Testing for Chef CLOUD SAVVY 14
  25. 25. TEST KITCHEN Convergence Integration Testing for Chef Does my cookbook work? CLOUD SAVVY 14
  26. 26. TEST KITCHEN NO Convergence Integration Testing for Chef Does my cookbook work? CLOUD SAVVY 14
  27. 27. FoodCritic Lint testing! Makes it easy to flag known issues Better Cookbooks! CLOUD SAVVY 15
  28. 28. Chef WorkFlowS CLOUD SAVVY
  29. 29. OLD CHEF DEV WORKFLOW CLOUD SAVVY 17
  30. 30. OLD CHEF DEV WORKFLOW Edit Cookbook CLOUD SAVVY 17
  31. 31. OLD CHEF DEV WORKFLOW Edit Cookbook Upload Cookbook CLOUD SAVVY 17
  32. 32. OLD CHEF DEV WORKFLOW Edit Cookbook Upload Cookbook Provision Machine CLOUD SAVVY 17
  33. 33. OLD CHEF DEV WORKFLOW Edit Cookbook Upload Cookbook Provision Machine Bootstrap Machine CLOUD SAVVY 17
  34. 34. OLD CHEF DEV WORKFLOW Edit Cookbook Upload Cookbook Run Chef Client Provision Machine Bootstrap Machine CLOUD SAVVY 17
  35. 35. OLD CHEF DEV WORKFLOW Edit Cookbook SSH & Validate Upload Cookbook Run Chef Client Provision Machine Bootstrap Machine CLOUD SAVVY 17
  36. 36. OLD CHEF DEV WORKFLOW Edit Cookbook SSH & Validate Upload Cookbook Run Chef Client Provision Machine Bootstrap Machine CLOUD SAVVY 17
  37. 37. NEW CHEF DEV WORKFLOW Edit Cookbook Test Kitchen Vagrant Up CLOUD SAVVY 18
  38. 38. Our Workflow Berkshelf Vagrant Up Test Kitchen GitHub CLOUD SAVVY Production Monitoring 19
  39. 39. Our Workflow Berkshelf Vagrant Up Test Kitchen GitHub CLOUD SAVVY Production Monitoring 19
  40. 40. Our Workflow { DEV Berkshelf Vagrant Up Test Kitchen GitHub CLOUD SAVVY Production Monitoring 19
  41. 41. Our Workflow OPS { { DEV Berkshelf Vagrant Up Test Kitchen GitHub CLOUD SAVVY Production Monitoring 19
  42. 42. Development Walkthrough Prerequisites CLOUD SAVVY
  43. 43. What You need • • • • • • • VirtualBox Vagrant Opscode’s 12.04 Vagrant Box Ruby (1.9.3 or higher!) Berkshelf Test Kitchen Foodcritic CLOUD SAVVY 21
  44. 44. Virtualbox https://www.virtualbox.org/wiki/Downloads CLOUD SAVVY 22
  45. 45. Vagrant http://downloads.vagrantup.com CLOUD SAVVY 23
  46. 46. OPSCODE’S VAGRANT BOX $  vagrant  box  add   opscode-­‐ubuntu-­‐12.04   http://tinyurl.com/chef1204   CLOUD SAVVY 24
  47. 47. CREATE A PROJECT $  mkdir  -­‐p  ~/projects/chefnovaclient $  cd  ~/projects/chefnovaclient CLOUD SAVVY 25
  48. 48. Berkshelf $  gem  install  berkshelf CLOUD SAVVY 26
  49. 49. Test Kitchen $  gem  install  test-­‐kitchen  -­‐-­‐pre CLOUD SAVVY 27
  50. 50. FoodCritic $  gem  install  foodcritic CLOUD SAVVY 28
  51. 51. CLOUD SAVVY 29
  52. 52. Development Walkthrough rackspace-novaclient & supernova CLOUD SAVVY
  53. 53. GET STARTED $  cd  ~/projects/chefnovaclient $  berks  init CLOUD SAVVY 31
  54. 54. $  berks  init berks  init            create    Berksfile            create    Thorfile            create    .gitignore                  run    git  init  from  "."            create    Gemfile            create    .kitchen.yml            append    Thorfile            create    test/integration/default            append    .gitignore            append    .gitignore            append    Gemfile            append    Gemfile You  must  run  `bundle  install'  to  fetch  any  new  gems.            create    Vagrantfile Successfully  initialized CLOUD SAVVY 32
  55. 55. $  berks  init berks  init            create    Berksfile            create    Thorfile            create    .gitignore                  run    git  init  from  "."            create    Gemfile            create    .kitchen.yml            append    Thorfile            create    test/integration/default            append    .gitignore            append    .gitignore            append    Gemfile            append    Gemfile You  must  run  `bundle  install'  to  fetch  any  new  gems.            create    Vagrantfile Successfully  initialized CLOUD SAVVY 33
  56. 56. $  berks  init berks  init            create    Berksfile            create    Thorfile            create    .gitignore                  run    git  init  from  "."            create    Gemfile            create    .kitchen.yml            append    Thorfile            create    test/integration/default            append    .gitignore            append    .gitignore            append    Gemfile            append    Gemfile You  must  run  `bundle  install'  to  fetch  any  new  gems.            create    Vagrantfile Successfully  initialized CLOUD SAVVY 34
  57. 57. $  berks  init berks  init            create    Berksfile            create    Thorfile            create    .gitignore                  run    git  init  from  "."            create    Gemfile            create    .kitchen.yml            append    Thorfile            create    test/integration/default            append    .gitignore            append    .gitignore            append    Gemfile            append    Gemfile You  must  run  `bundle  install'  to  fetch  any  new  gems.            create    Vagrantfile Successfully  initialized CLOUD SAVVY 35
  58. 58. $  berks  init berks  init            create    Berksfile            create    Thorfile            create    .gitignore                  run    git  init  from  "."            create    Gemfile            create    .kitchen.yml            append    Thorfile            create    test/integration/default            append    .gitignore            append    .gitignore            append    Gemfile            append    Gemfile You  must  run  `bundle  install'  to  fetch  any  new  gems.            create    Vagrantfile Successfully  initialized CLOUD SAVVY 36
  59. 59. $  berks  init berks  init            create    Berksfile            create    Thorfile            create    .gitignore                  run    git  init  from  "."            create    Gemfile            create    .kitchen.yml            append    Thorfile            create    test/integration/default            append    .gitignore            append    .gitignore            append    Gemfile            append    Gemfile You  must  run  `bundle  install'  to  fetch  any  new  gems.            create    Vagrantfile Successfully  initialized CLOUD SAVVY 37
  60. 60. $  berks  init berks  init            create    Berksfile            create    Thorfile            create    .gitignore                  run    git  init  from  "."            create    Gemfile            create    .kitchen.yml            append    Thorfile            create    test/integration/default            append    .gitignore            append    .gitignore            append    Gemfile            append    Gemfile You  must  run  `bundle  install'  to  fetch  any  new  gems.            create    Vagrantfile Successfully  initialized CLOUD SAVVY 38
  61. 61. CLOUD SAVVY 39
  62. 62. INSTALL Kitchen-Vagrant $  gem  install  kitchen-­‐vagrant CLOUD SAVVY 40
  63. 63. SET UP TEST KITCHEN Goodbye 10.04! CLOUD SAVVY 41
  64. 64. RUN Test KitchEN $  kitchen  verify Good Luck! CLOUD SAVVY 42
  65. 65. CLOUD SAVVY 43
  66. 66. WHAT FAILED? FATAL:  No  cookbook  found CLOUD SAVVY 44
  67. 67. What are our requirements? CLOUD SAVVY 45
  68. 68. What are our requirements? Python pip make package manager setuptools CLOUD SAVVY 45
  69. 69. COPY/PasTE http://tinyurl.com/chefpart2 CLOUD SAVVY 46
  70. 70. BERKSFILE: DependencIES! site  :opscode cookbook  'apt' cookbook  'build-­‐essential' cookbook  'python' CLOUD SAVVY 47
  71. 71. RUN Test KitchEN $  kitchen  converge Good Luck! CLOUD SAVVY 48
  72. 72. Congrats! You installed something... CLOUD SAVVY 49
  73. 73. Congrats! You installed something... but not what we need. CLOUD SAVVY 49
  74. 74. BERKSFILE: THIS IS A COOKBOOK site  :opscode cookbook  'apt' cookbook  'build-­‐essential' cookbook  'python' metadata CLOUD SAVVY 50
  75. 75. BERKSFILE: THIS IS A COOKBOOK site  :opscode cookbook  'apt' cookbook  'build-­‐essential' cookbook  'python' metadata CLOUD SAVVY 51
  76. 76. RUN Test KitchEN $  kitchen  converge Good Luck! CLOUD SAVVY 52
  77. 77. CLOUD SAVVY 53
  78. 78. WHAT FAILED? Failed  to  complete  #converge  action CLOUD SAVVY 54
  79. 79. metadata.RB: What is this THING?? name  "chefnovaclient" version  "1.0.0" description  "Installs  the  novaclient." maintainer  "Hart  Hoover" maintainer_email  "hart.hoover@rackspace.com" depends  "python" depends  "apt" supports  "ubuntu" CLOUD SAVVY 55
  80. 80. RUN Test KitchEN $  kitchen  converge Good Luck! CLOUD SAVVY 56
  81. 81. Congrats! You installed something... CLOUD SAVVY 57
  82. 82. Congrats! You installed something... but STILL not what we need. CLOUD SAVVY 57
  83. 83. TIME TO WRITE RECIPES CLOUD SAVVY 58
  84. 84. TIME TO WRITE RECIPES $  berks  cookbook  . Don’t overwrite stuff CLOUD SAVVY 59
  85. 85. Default RECIPE: recipes/default.rb include_recipe  "apt" include_recipe  "python::pip" %w{git  python-­‐dev  build-­‐essential}.each  do  |pkg|   package  pkg  do     action  :install   end end python_pip  "rackspace-­‐novaclient"  do   action  :install end CLOUD SAVVY 60
  86. 86. Default RECIPE: recipes/default.rb include_recipe  "apt" include_recipe  "python::pip" %w{git  python-­‐dev  build-­‐essential}.each  do  |pkg|   package  pkg  do     action  :install   end end python_pip  "rackspace-­‐novaclient"  do   action  :install end CLOUD SAVVY 61
  87. 87. Default RECIPE: recipes/default.rb include_recipe  "apt" include_recipe  "python::pip" %w{git  python-­‐dev  build-­‐essential}.each  do  |pkg|   package  pkg  do     action  :install   end end python_pip  "rackspace-­‐novaclient"  do   action  :install end CLOUD SAVVY 62
  88. 88. Default RECIPE: recipes/default.rb include_recipe  "apt" include_recipe  "python::pip" %w{git  python-­‐dev  build-­‐essential}.each  do  |pkg|   package  pkg  do     action  :install   end end python_pip  "rackspace-­‐novaclient"  do   action  :install end CLOUD SAVVY 63
  89. 89. EDIT YOUR RUN LIST .kitchen.yaml suites: -­‐  name:  default    run_list:        -­‐  recipe[chefnovaclient::default]    attributes:  {} CLOUD SAVVY 64
  90. 90. EDIT YOUR RUN LIST .kitchen.yaml suites: -­‐  name:  default    run_list:        -­‐  recipe[chefnovaclient::default]    attributes:  {} CLOUD SAVVY 65
  91. 91. RUN FOODCRITIC! $  foodcritic  . Everything good? CLOUD SAVVY 66
  92. 92. If Not: FIX IT! CLOUD SAVVY 67
  93. 93. RUN Test KitchEN $  kitchen  converge Good Luck! CLOUD SAVVY 68
  94. 94. Did it work? $  kitchen  login  default $  nova  help CLOUD SAVVY 69
  95. 95. CLOUD SAVVY 70
  96. 96. CLOUD SAVVY 71
  97. 97. SUPERNOVA CLOUD SAVVY 72
  98. 98. Let’s MAKE AUTOMATED TESTs $  mkdir  test/integration/default/bats $  touch  test/integration/default/bats/supernova.bats CLOUD SAVVY 73
  99. 99. TESTING test/integration/default/bats/supernova.bats #!/usr/bin/env  bats @test  "supernova  is  installed"  {    which  supernova } CLOUD SAVVY 74
  100. 100. TESTING test/integration/default/bats/supernova.bats @test  "supernova  config  exists"  {    cat  /home/vagrant/.supernova } CLOUD SAVVY 75
  101. 101. TESTING test/integration/default/bats/supernova.bats @test  "run  supernova"  {    supernova  myaccount  list } CLOUD SAVVY 76
  102. 102. TESTING test/integration/default/bats/supernova.bats @test  "novaclient  installed"  {    which  nova } CLOUD SAVVY 77
  103. 103. SUPERNOVA recipes/default.rb python_pip  "git+git://github.com/major/supernova.git"  do   action  :install end template  "/home/vagrant/.supernova"  do    source  "supernova.erb"    mode  0600    owner  "vagrant"    group  "vagrant" end CLOUD SAVVY 78
  104. 104. SuperNova templates/default/supernova.erb [myaccount] OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/ OS_VERSION=2.0 OS_AUTH_SYSTEM=rackspace OS_REGION_NAME=DFW OS_SERVICE_NAME=cloudserversOpenStack OS_TENANT_NAME=<%=  node['chefnovaclient']['username']  %> OS_USERNAME=<%=  node['chefnovaclient']['username']  %> OS_PASSWORD=<%=  node['chefnovaclient']['password']  %> OS_NO_CACHE=1 NOVA_VOLUME_SERVICE_NAME=cloudBlockStorage CLOUD SAVVY 79
  105. 105. SuperNova templates/default/supernova.erb [myaccount] OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/ OS_VERSION=2.0 OS_AUTH_SYSTEM=rackspace OS_REGION_NAME=DFW OS_SERVICE_NAME=cloudserversOpenStack OS_TENANT_NAME=<%=  node['chefnovaclient']['username']  %> OS_USERNAME=<%=  node['chefnovaclient']['username']  %> OS_PASSWORD=<%=  node['chefnovaclient']['password']  %> OS_NO_CACHE=1 NOVA_VOLUME_SERVICE_NAME=cloudBlockStorage CLOUD SAVVY 80
  106. 106. SuperNova attributes/default.rb default['chefnovaclient']['username']  =  "USERNAME" default['chefnovaclient']['password']  =  "APIKEY" CLOUD SAVVY 81
  107. 107. RUN FOODCRITIC! $  foodcritic  . Everything good? CLOUD SAVVY 82
  108. 108. RUN Test KitchEN $  kitchen  converge Good Luck! CLOUD SAVVY 83
  109. 109. RUN YOUR Tests $  kitchen  verify Good Luck! CLOUD SAVVY 84
  110. 110. “SAVE YOUR WORK” CLOUD SAVVY 85
  111. 111. THANK YOU! CLOUD SAVVY

×