More Related Content Similar to Atmosphere 2014 (20) Atmosphere 20144. berkshelf
Chef Cookbook manager and
dependency resolver
» Retrieve a cookbooks
dependencies
» Package cookbooks and their
dependencies
» Author new cookbooks
5. » League of Legends
» Guild Wars 2
» TERA
» Lord of The Rings Online
» Dungeons and Dragons Online
» Asheron's Call
12. Risk is exponentiallygreater
irb> changes = ChangeSet.new
irb> changes.add Change.new
irb> changes.risk_level
=> 1
irb> 5.times do
irb> changes.add Change.new
irb> end
irb> changes.risk_level
=> 46656
Risk Level: 6 ^ 6
14. Notdeployingat5PM is:
1.Killing Peter
a. Framing it as a suicide
b. Making his wife your wife
c. Stealing his entire family inheritence
d. Telling his children you're their new dad
e. Defecating on his grave
To payPaul
27. DevOps is not
» A position
» A team
» A department
» Or an organization
49. CookbookAndApplication Share
Version
$ cat cookbook/metadata.rb
name "highfive"
maintainer "Jamie Winsor"
maintainer_email "jamie@vialstudios.com"
license "All rights reserved"
description "Installs/Configures highfive"
long_description "Installs/Configures highfive"
version File.read(File.expand_path("../../VERSION", __FILE__))
51. $ cat cookbook/libraries/highfive.rb
#
# Cookbook Name:: highfive
# Libraries:: highfive
#
module Highfive
module Chef
class << self
# Returns the version of the loaded highfive cookbook
#
# @param [Chef::RunContext] context
#
# @return [String]
def cookbook_version(context)
context.cookbook_collection["highfive"].version
end
end
end
end
59. Build Server Recipe
$ cat cookbook/recipe/build_server.rb
include_recipe "highfive::_common"
include_recipe "build-essential::default"
include_recipe "elixir::default"
60. Editmetadata.rb
$ cat cookbook/metadata.rb
name "highfive"
maintainer "Jamie Winsor"
maintainer_email "jamie@vialstudios.com"
license "All rights reserved"
description "Installs/Configures highfive"
long_description "Installs/Configures highfive"
version "0.1.0"
supports "ubuntu"
depends "build-essential", "~> 2.0"
depends "elixir", "~> 0.5"
62. Vagrant.configure("2") do |config|
# ... additional configuration ...
config.vm.synced_folder File.dirname(__FILE__), "/builder"
config.vm.provision :chef_solo do |chef|
chef.run_list = [ "recipe[highfive::build_server]" ]
end
config.vm.provision :shell, inline: <<-SCRIPT
export PATH=/usr/local/lib/elixir/bin::$PATH
export ELIXIR_EBIN=/usr/local/lib/elixir/lib/elixir/ebin
export MIX_ENV=prod
mix clean --all
mix version.bump patch
mix deps.get
mix compile
mix release.assemble
mix package
SCRIPT
end
63. Build it(from our hostmachine)
$ vagrant up --provision
.... provisioning ...
$ ls pkg
highfive-linux-x86-tar.gz
65. Create app.rb recipe
node.set[:'build-essential'][:compile_time] = true
include_recipe "libarchive::default"
include_recipe "runit"
libarchive_file "highfive-linux-x86.tar.gz" do
path "/pkg"
extract_to "/opt/highfive"
owner "highfive"
group "highfive"
action :extract
notifies :restart, "runit_service[highfive]"
only_if { ::File.exist?(asset.asset_path) }
end
runit_service "highfive"
68. Kitchen Converge
$ cd cookbook
$ kitchen converge
-----> Starting Kitchen (v1.2.2.dev)
...
-----> Kitchen is finished. (14m6.31s)
70. Thearchive contains
» The Berksfile.lock from resolution
» A cookbooks directory containing each cookbook
found in the Berksfile.lock
72. ArtifactServers
» Github | Github Enterprise
» Sonatype's Nexus
» Artifactory
» Basic Auth HTTP Server (sadface)
(https://artifacts.myorg.com/myapp/1.2.3/
myapp.tar.gz)
75. GitHub Deploy
asset_path = "/pkg"
unless node[:highfive][:_local_deploy]
asset = github_asset "berkshelf-api.tar.gz" do
repo "berkshelf/berkshelf-api"
release "v1.2.1"
end
asset_path = asset.path
end
libarchive_file "highfive-linux-x86.tar.gz" do
path asset_path
extract_to "/opt/highfive"
owner "highfive"
group "highfive"
action :extract
notifies :restart, "runit_service[highfive]"
only_if { ::File.exist?(asset.asset_path) }
end
77. Releaseartifactsallowusto
» Build a new environment with a specific version
» Upgrade pre-existing environments
» Promote through logical environments
(Dev, Stage, Production)