Your SlideShare is downloading. ×
0
Whatdo I dowith my
hands
Andwhyis my
posture so bad
ByJamieWinsor
3.0 released
April13th 2014
berkshelf
Chef Cookbook manager and
dependency resolver
» Retrieve a cookbooks
dependencies
» Package cookbooks and
their ...
BerkshelfCoreTeam
» Jamie Winsor <jamie@vialstudios.com>
» Seth Vargo <sethvargo@gmail.com>
» Michael Ivey <michael.ivey@r...
The BerkshelfWay
» Introduction to Chef Cookbooks
» Introduction to Cookbook Patterns
» Best practices in
» Cookbook devel...
“Berkshelf
doesn'twork
for my
workflow”
A lot of smart people
“Uhhh...yeah it
does”
Me
Automation is dangerous unless
» It is portable
» It is repeatable
» It is predictable
Ifit's notthetool
whatis it?
Software doesn't
solve problems.
People do.
“Ifyou putthe right
people inthe right
roomthey'llsolve
the problemthe
rightway”
Jeff Hackert
Yourworkflowmightneed
to change
DevOps isasoftware
developmentpattern
DevOps is not
» A position
» A team
» A department
» Or an organization
“Disruptive startup
is hiring DevOps
ninjas”
LinkedIn Spammer
ComingTogether
The BerkshelfVision
Howdowe createa
self contained
release?
The 3 Requirements For Self
Contained Releases
1.Software Artifact (berkshelf-api.tar.gz)
2.Cookbook Artifact (berkshelf-a...
Ifyou'readeveloper
Give these three things to your Operators for every
release.
Ifyou'rean Operator
You should be receiving these three things for every
release.
Ifyou're both,
Throw a fucking pizza party
Withthose 3thingsyou can
» Build a new environment with a specific version
» Upgrade pre-existing environments
» Promote th...
Automation is dangerous unless
» It is portable
» It is repeatable
» It is predictable
Putthose 3things in
anartifactserver
ArtifactServers
» Github | Github Enterprise
» Sonatype's Nexus
» Artifactory
» Basic Auth HTTP Server (sadface)
(https://...
Github Releasesand
ReleaseAssets
Generatingyour
releaseartifacts
The SoftwareArtifact
1.Bump version
2.Compile w/ dependencies
3.Test
4.Package
(myapp.tar.gz)
The CookbookArtifact
Pre-requisites
» Resides in the same repository as your software
» Shares the same version number as ...
EnvironmentCookbook
» Nearly identical to an Application Cookbook
» Has it's Berksfile.lock committed into version
control
...
How does itwork?
The Berksfile.lock is distributed with the cookbook
so it can be "applied" to a Chef Environment
$ berks a...
Berkshelf-API Server Example
» Code in lib/
» Binaries in bin/
» Cookbook in cookbook/
» cookbook/Berksfile.lock present in...
$ cat cookbook/metadata.rb
lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include...
Or with a VERSION file at the root of your
application
$ cat cookbook/metadata.rb
name "some-app"
maintainer "Jamie Winsor"...
$ cat cookbook/attributes/default.rb
#
# Cookbook Name:: berkshelf-api
# Attribute:: default
#
default[:berkshelf_api][:re...
$ cat cookbook/libraries/berkshelf_api.rb
#
# Cookbook Name:: berkshelf-api
# Libraries:: berkshelf_api
#
module Berkshelf...
Generatingthe Cookbookartifact
$ cd cookbook/
$ berks package
Cookbook(s) packaged to cookbooks-1397345842.tar.gz
Thearchi...
How do I gettheartifacts intoa
Github release?
» Octokit & Rake/Thor
» Create a release manually and attach the asset
(boo...
Howdo I getthe
artifacts out?
Github Cookbook
Provides an LWRP for downloading
» An asset from a Github release
» An archive containing source code from...
$ cat cookbook/metadata.rb
name "berkshelf-api"
maintainer "Jamie Winsor"
maintainer_email "jamie@vialstudios.com"
# ... o...
$ cat cookbook/recipes/app.rb
node.set[:'build-essential'][:compile_time] = true
include_recipe "build-essential::default"...
The StorySo Far
» We have an encapsulated release containing
» A software artifact
» A cookbook artifact
» And you wrote a...
Solving Distribution
Berkflow
ACookbook-Centric
Deploymentworkflowtool
InstallBerkflowwith Chef-DK
$ sudo chef gem install berkflow
$ export PATH=/opt/chefdk/embedded/bin:$PATH
$ which blo
/opt/c...
"Install"the cookbookartifact
intoyour ChefServer
$ blo install https://github.com/berkshelf/berkshelf-api/releases/downlo...
"Upgrading"aChefEnvironment
$ blo upgrade berks-api-dev berkshelf-api 1.2.1
Or upgrade to latest
$ blo upgrade berks-api-d...
One Button Upgrade
WannaMake Games?
http://undeadlabs.com/jobs/
» Game Programmer
» Game Producer
» Game Animator
» Game Designer
ExternalResources
» http://berkshelf.com
» http://getchef.com/downloads/chef-dk
» https://github.com/berkshelf/berkshelf
»...
JamieWinsor
@resetexistence
github.com/reset
Chef conf-2014
Chef conf-2014
Chef conf-2014
Chef conf-2014
Chef conf-2014
Chef conf-2014
Chef conf-2014
Upcoming SlideShare
Loading in...5
×

Chef conf-2014

3,133

Published on

The Berkshelf Vision

1 Comment
12 Likes
Statistics
Notes
No Downloads
Views
Total Views
3,133
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
34
Comments
1
Likes
12
Embeds 0
No embeds

No notes for slide

Transcript of "Chef conf-2014"

  1. 1. Whatdo I dowith my hands Andwhyis my posture so bad ByJamieWinsor
  2. 2. 3.0 released April13th 2014
  3. 3. berkshelf Chef Cookbook manager and dependency resolver » Retrieve a cookbooks dependencies » Package cookbooks and their dependencies » Author new cookbooks
  4. 4. BerkshelfCoreTeam » Jamie Winsor <jamie@vialstudios.com> » Seth Vargo <sethvargo@gmail.com> » Michael Ivey <michael.ivey@riotgames.com>
  5. 5. The BerkshelfWay » Introduction to Chef Cookbooks » Introduction to Cookbook Patterns » Best practices in » Cookbook development » Cookbook management » Avoiding pitfalls » How to iterate quickly Last year I gave a talk at ChefConf called The
  6. 6. “Berkshelf doesn'twork for my workflow” A lot of smart people
  7. 7. “Uhhh...yeah it does” Me
  8. 8. Automation is dangerous unless » It is portable » It is repeatable » It is predictable
  9. 9. Ifit's notthetool whatis it?
  10. 10. Software doesn't solve problems. People do.
  11. 11. “Ifyou putthe right people inthe right roomthey'llsolve the problemthe rightway” Jeff Hackert
  12. 12. Yourworkflowmightneed to change
  13. 13. DevOps isasoftware developmentpattern
  14. 14. DevOps is not » A position » A team » A department » Or an organization
  15. 15. “Disruptive startup is hiring DevOps ninjas” LinkedIn Spammer
  16. 16. ComingTogether
  17. 17. The BerkshelfVision
  18. 18. Howdowe createa self contained release?
  19. 19. The 3 Requirements For Self Contained Releases 1.Software Artifact (berkshelf-api.tar.gz) 2.Cookbook Artifact (berkshelf-api-cookbooks.tar.gz) 3.Installation | Upgrade | Configuration Docs
  20. 20. Ifyou'readeveloper Give these three things to your Operators for every release.
  21. 21. Ifyou'rean Operator You should be receiving these three things for every release.
  22. 22. Ifyou're both, Throw a fucking pizza party
  23. 23. Withthose 3thingsyou can » Build a new environment with a specific version » Upgrade pre-existing environments » Promote through logical environments (Dev, Stage, Production)
  24. 24. Automation is dangerous unless » It is portable » It is repeatable » It is predictable
  25. 25. Putthose 3things in anartifactserver
  26. 26. ArtifactServers » Github | Github Enterprise » Sonatype's Nexus » Artifactory » Basic Auth HTTP Server (sadface) (https://artifacts.myorg.com/myapp/1.2.3/ myapp.tar.gz)
  27. 27. Github Releasesand ReleaseAssets
  28. 28. Generatingyour releaseartifacts
  29. 29. The SoftwareArtifact 1.Bump version 2.Compile w/ dependencies 3.Test 4.Package (myapp.tar.gz)
  30. 30. The CookbookArtifact Pre-requisites » Resides in the same repository as your software » Shares the same version number as your compiled software » Deploys an archive of the software matching the cookbook's version (by default) » Follows the Environment Cookbook pattern
  31. 31. EnvironmentCookbook » Nearly identical to an Application Cookbook » Has it's Berksfile.lock committed into version control Generate an environment cookbook with: $ berks cookbook {myapp} --pattern environment
  32. 32. How does itwork? The Berksfile.lock is distributed with the cookbook so it can be "applied" to a Chef Environment $ berks apply berks-api-dev -b ~/Downloads/berkshelf-api/Berksfile.lock This sets an equality lock in the Chef Environment (berks-api-dev) for each cookbook in the lockfile
  33. 33. Berkshelf-API Server Example » Code in lib/ » Binaries in bin/ » Cookbook in cookbook/ » cookbook/Berksfile.lock present in version control
  34. 34. $ cat cookbook/metadata.rb lib = File.expand_path('../../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'berkshelf/api/version' name "berkshelf-api" maintainer "Jamie Winsor" maintainer_email "jamie@vialstudios.com" license "Apache 2.0" description "Installs/Configures a berkshelf-api server" long_description "Installs/Configures a berkshelf-api server" version Berkshelf::API::VERSION
  35. 35. Or with a VERSION file at the root of your application $ cat cookbook/metadata.rb name "some-app" maintainer "Jamie Winsor" maintainer_email "jamie@vialstudios.com" version File.read(File.expand_path("../../VERSION", __FILE__)) # ...other metadata...
  36. 36. $ cat cookbook/attributes/default.rb # # Cookbook Name:: berkshelf-api # Attribute:: default # default[:berkshelf_api][:release] = "v#{Berkshelf::API::Chef.cookbook_version(run_context)}"
  37. 37. $ cat cookbook/libraries/berkshelf_api.rb # # Cookbook Name:: berkshelf-api # Libraries:: berkshelf_api # module Berkshelf module API module Chef class << self # Returns the version of the loaded berkshelf-api cookbook # # @param [Chef::RunContext] context # # @return [String] def cookbook_version(context) context.cookbook_collection["berkshelf-api"].version end end end end end
  38. 38. Generatingthe Cookbookartifact $ cd cookbook/ $ berks package Cookbook(s) packaged to cookbooks-1397345842.tar.gz Thearchive contains » The Berksfile.lock from resolution » A cookbooks directory containing each cookbook found in the Berksfile.lock
  39. 39. How do I gettheartifacts intoa Github release? » Octokit & Rake/Thor » Create a release manually and attach the asset (boo.)
  40. 40. Howdo I getthe artifacts out?
  41. 41. Github Cookbook Provides an LWRP for downloading » An asset from a Github release » An archive containing source code from a tag, branch, or revision Libarchive Cookbook Provides an LWRP for idempotently extracting archives
  42. 42. $ cat cookbook/metadata.rb name "berkshelf-api" maintainer "Jamie Winsor" maintainer_email "jamie@vialstudios.com" # ... other metadata ... depends "github" depends "libarchive" depends "build-essential", "~> 2.0"
  43. 43. $ cat cookbook/recipes/app.rb node.set[:'build-essential'][:compile_time] = true include_recipe "build-essential::default" asset = github_asset "berkshelf-api.tar.gz" do repo "berkshelf/berkshelf-api" release "v1.2.1" end libarchive_file "berkshelf-api.tar.gz" do path asset.asset_path extract_to "/opt/berkshelf-api/v1.2.1" owner "berkshelf" group "berkshelf" action :extract notifies :restart, "runit_service[berks-api]" only_if { ::File.exist?(asset.asset_path) } end
  44. 44. The StorySo Far » We have an encapsulated release containing » A software artifact » A cookbook artifact » And you wrote and committed a README containing installation/configuration instructions » It's located on an artifact server » Bonus round: The release is also tied to the version control ref it was built from
  45. 45. Solving Distribution
  46. 46. Berkflow ACookbook-Centric Deploymentworkflowtool
  47. 47. InstallBerkflowwith Chef-DK $ sudo chef gem install berkflow $ export PATH=/opt/chefdk/embedded/bin:$PATH $ which blo /opt/chefdk/embedded/bin/blo Install with sudo for now: (https://github.com/opscode/chef-dk/issues/11)
  48. 48. "Install"the cookbookartifact intoyour ChefServer $ blo install https://github.com/berkshelf/berkshelf-api/releases/download/v1.2.1/cookbooks.tar.gz
  49. 49. "Upgrading"aChefEnvironment $ blo upgrade berks-api-dev berkshelf-api 1.2.1 Or upgrade to latest $ blo upgrade berks-api-dev berkshelf-api latest
  50. 50. One Button Upgrade
  51. 51. WannaMake Games? http://undeadlabs.com/jobs/ » Game Programmer » Game Producer » Game Animator » Game Designer
  52. 52. ExternalResources » http://berkshelf.com » http://getchef.com/downloads/chef-dk » https://github.com/berkshelf/berkshelf » https://github.com/berkshelf/berkshelf-api » https://github.com/reset/berkflow » https://github.com/reset/libarchive-cookbook » https://github.com/reset/github-cookbook
  53. 53. JamieWinsor @resetexistence github.com/reset
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×