london community summit 2016 - fresh new chef stuff

39
Fresh New Chef Stuff Thom May & Tim Smith - Community Engineering

Upload: chef

Post on 08-Jan-2017

156 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: London Community Summit 2016 - Fresh New Chef Stuff

Fresh New Chef StuffThom May & Tim Smith - Community Engineering

Page 2: London Community Summit 2016 - Fresh New Chef Stuff

Chef Year in Review

Page 3: London Community Summit 2016 - Fresh New Chef Stuff

10 chef client releases

7 chef server releases

13 ohai releases

Page 4: London Community Summit 2016 - Fresh New Chef Stuff

7,000+ commits across chef projects!

7,000+ more in chef managed community cookbooks!

Page 5: London Community Summit 2016 - Fresh New Chef Stuff

- apt_update- apt_repository- yum_repository- systemd_unit- chocolatey_package- cab_package- launchd- osx_profile- ksh

New Chef Resources

Page 6: London Community Summit 2016 - Fresh New Chef Stuff

- shard- machineid- hostnamectl- shells- hardware- time- fips- scala- sessions- packages

New Ohai Plugins

Page 7: London Community Summit 2016 - Fresh New Chef Stuff

Do yourself a favour and upgrade!

Page 8: London Community Summit 2016 - Fresh New Chef Stuff

Let’s jump into some new stuff!

Page 9: London Community Summit 2016 - Fresh New Chef Stuff

Custom Resources

Page 10: London Community Summit 2016 - Fresh New Chef Stuff

Custom resources are reusable Chef resources you define within your cookbooks

that make it easy to automate repetitive tasks within your organization’s cookbooks

Page 11: London Community Summit 2016 - Fresh New Chef Stuff

Custom resources build on the foundations of Lightweight Resource Providers (LWRPs) with powerful new functionality and a simpler DSL

Page 12: London Community Summit 2016 - Fresh New Chef Stuff

Custom Resources• Introduced in Chef 12.5• Compatible with Chef 12.1+ using the compat_resource

cookbook• Build on years of LWRP experience and development

Page 13: London Community Summit 2016 - Fresh New Chef Stuff

Improvements compared to LWRPs• Everything is defined in a single file• Greatly simplified DSL• New DSL for supporting multiple platforms / platform versions• “Just works” out of the box

Page 14: London Community Summit 2016 - Fresh New Chef Stuff

resources/myapp.rb file:

actions :createdefault_action :create

attribute :name, kind_of: String, name_attribute: trueattribute :app_name, kind_of: String, default: 'default_app'

providers/myapp.rb file:

use_inline_resources

def whyrun_supported? trueend

action :create do template '/some/web/app/config' do owner 'root' group 'root' variables(app_name: new_resource.app_name) notifies :restart, 'service[apache2]' end

service 'apache2' do action :nothing endend

resources/myapp.rb file:

property :name, String, name_attribute: trueproperty :app_name, String, default: 'default_app'

action :create do template '/some/web/app/config' do owner 'root' group 'root' variables(app_name: new_resource.app_name) notifies :restart, 'service[apache2]' endend

Simplified DSL in Action:

Page 15: London Community Summit 2016 - Fresh New Chef Stuff

Fresh New Chef Stuff Episode 1: Custom Resources Youtube Video

http://bit.ly/2dqpMJg

Page 16: London Community Summit 2016 - Fresh New Chef Stuff

Chef Solo

Page 17: London Community Summit 2016 - Fresh New Chef Stuff

Chef Solo now uses the same technology as Chef Client Local Mode

Page 18: London Community Summit 2016 - Fresh New Chef Stuff

Editing and Deleting Resources

Page 19: London Community Summit 2016 - Fresh New Chef Stuff

The Chef Rewind extension is no longer required - Chef 12.10 and later.

Page 20: London Community Summit 2016 - Fresh New Chef Stuff

DeletePreviously:

chef_gem "chef-rewind"require 'chef/rewind'unwind "user[postgres]"

Now: delete_resource(:user,”postgres")

Page 21: London Community Summit 2016 - Fresh New Chef Stuff

EditPreviously:

chef_gem "chef-rewind"require 'chef/rewind'rewind “user[postgres]" do

home “/var/lib/postgres”end

Now: edit_resource!(:user,”postgres”) do

home “/var/lib/postgres”end

Page 22: London Community Summit 2016 - Fresh New Chef Stuff

Built in Apt/Yum resources

Page 23: London Community Summit 2016 - Fresh New Chef Stuff

name "my_cookbook"maintainer "Me"maintainer_email "[email protected]"license "Apache 2.0"version "1.0.0"

depends "apt"depends "yum"

Page 24: London Community Summit 2016 - Fresh New Chef Stuff

Prep Debian / Ubuntu package cache

apt_update "Update Please"

include_recipe "apt::default"

Page 25: London Community Summit 2016 - Fresh New Chef Stuff

Setup package repositories

apt_repository "OurCo" do uri "http://artifacts.ourco.org/ubuntu/something" action :true components ["main"]end

yum_repository "OurCo" do description "OurCo Yum repository" mirrorlist "http://artifacts.ourco.org/mirrorlist?repo=ourco-6&arch=$basearch gpgkey "http://artifacts.ourco.org/pub/yum/RPM-GPG-KEY-OURCO-6" action :createend

Page 26: London Community Summit 2016 - Fresh New Chef Stuff

Multi Package

Page 27: London Community Summit 2016 - Fresh New Chef Stuff

Multiple PackagesPreviously: %w{ httpd jenkins tmux }.each do |pkg|package pkg

end

Now: package %w{ httpd jenkins tmux }

Page 28: London Community Summit 2016 - Fresh New Chef Stuff

macOS Improvements

Page 29: London Community Summit 2016 - Fresh New Chef Stuff

New Resources for macOSlaunchd (Chef 12.8.1)

osx_profile (Chef 12.7.0)

Page 30: London Community Summit 2016 - Fresh New Chef Stuff

Big thanks to Facebook for their macOS work

Page 31: London Community Summit 2016 - Fresh New Chef Stuff

Cookbook Gem Dependencies

Page 32: London Community Summit 2016 - Fresh New Chef Stuff

PreviouslyRecipe:

chef_gem "docker" do compile_time trueend

Library:

begin require 'docker'rescue LoadError puts "waiting to load Docker"end

Page 33: London Community Summit 2016 - Fresh New Chef Stuff

Now (in12.9.1)metadata.rb:

gem "docker"

Library:

require 'docker'

Page 34: London Community Summit 2016 - Fresh New Chef Stuff

Windows Improvements

Page 35: London Community Summit 2016 - Fresh New Chef Stuff

New Resourceschocolatey_package (Chef 12.7.0)

cab_package (Chef 12.15.19)

Page 36: London Community Summit 2016 - Fresh New Chef Stuff

Newly Built in Windows Resources• reboot• batch• registry• package

Page 37: London Community Summit 2016 - Fresh New Chef Stuff

name “my_windows_cookbook"maintainer "Me"maintainer_email "[email protected]"license "Apache 2.0"version "1.0.0"

depends "windows"

Page 38: London Community Summit 2016 - Fresh New Chef Stuff

systemd_unit (since 12.11)

Page 39: London Community Summit 2016 - Fresh New Chef Stuff

More built-insSimpler DSLs

Expanded platform support