Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Hand Crafted Artisinal Chef Resources
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
someara
February 02, 2016
Technology
0
590
Hand Crafted Artisinal Chef Resources
Configuration Management Camp
Ghent Belgium
February 2016
someara
February 02, 2016
Tweet
Share
More Decks by someara
See All by someara
Docker Docker Docker Chef
someara
0
480
Configuration Management Camp 2015
someara
1
560
Cookbook Reusability
someara
0
790
TDI with ChefDK 0.0.1
someara
2
870
Configuration Management 101 @ Scale12x
someara
2
880
Configuration Management 101
someara
3
770
Introduction to Chef - Scale 10x
someara
2
450
Introduction to Chef - NYLUG Jan 2012
someara
2
300
Introduction to Chef - LISA11
someara
10
6.2k
Other Decks in Technology
See All in Technology
開発メンバーが語るFindy Conferenceの裏側とこれから
sontixyou
2
420
ゼロから始めたFindy初のモバイルアプリ開発
grandbig
2
550
Amazon ElastiCacheのコスト最適化を考える/Elasticache Cost Optimization
quiver
0
330
Deno・Bunの標準機能やElysiaJSを使ったWebSocketサーバー実装 / ラーメン屋を貸し切ってLT会! IoTLT 2026新年会
you
PRO
0
190
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
4
610
セキュリティについて学ぶ会 / 2026 01 25 Takamatsu WordPress Meetup
rocketmartue
1
150
システムのアラート調査をサポートするAI Agentの紹介/Introduction to an AI Agent for System Alert Investigation
taddy_919
2
1.1k
DatabricksホストモデルでAIコーディング環境を構築する
databricksjapan
0
210
ファインディの横断SREがTakumi byGMOと取り組む、セキュリティと開発スピードの両立
rvirus0817
1
650
AIとともに歩む情報セキュリティ / Information Security with AI
kanny
4
2.8k
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
100
月間数億レコードのアクセスログ基盤を無停止・低コストでAWS移行せよ!アプリケーションエンジニアのSREチャレンジ💪
miyamu
0
450
Featured
See All Featured
A better future with KSS
kneath
240
18k
Building the Perfect Custom Keyboard
takai
2
680
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
61
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.6k
Building Applications with DynamoDB
mza
96
6.9k
Site-Speed That Sticks
csswizardry
13
1k
The Pragmatic Product Professional
lauravandoore
37
7.1k
Designing for Timeless Needs
cassininazir
0
120
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
HDC tutorial
michielstock
1
330
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
150
Building AI with AI
inesmontani
PRO
1
660
Transcript
Hand Crafted Artisanal Chef Resources
Config Management Camp Ghent, Belgium February 2016
Sean OMeara
[email protected]
@someara
whoami
Part 1
Writing library cookbooks An opinionated workflow Step by step
Step 1 - Disregard dogma “Unit tests first” is a
dirty lie https://flic.kr/p/aTSiXF
Step 2 - Make things up Then work backwards https://flic.kr/p/dXkQ5s
Contrived examples are the best examples
None
Place this off to the side, we will come back
for it later.
Step 3 - Create a cookbook By hand. Be a
wizard. https://flic.kr/p/3mMW6e
mkdir -p ~/src/custom-resources-tutorial cd ~/src/custom-resources-tutorial emacs metadata.rb
None
Step 4 - Embed a test cookbook. By hand. Be
a wizard. Again. https://flic.kr/p/ai36NG
mkdir -p test/cookbooks/my_file_test cd test/cookbooks/my_file_test echo “test cookbook” > README.md
mkdir recipes touch recipes/default.rb emacs metadata.rb
None
Step 5 - Tell Berkshelf about it https://flic.kr/p/k5jmja
cd ~/src/custom-resources-tutorial emacs Berksfile
None
Step 6 - Configure Test Kitchen https://flic.kr/p/r38F5c
emacs .kitchen.yml
None
kitchen test ; echo $?
Step 7 - Save game https://flic.kr/p/6ZJ4G7
cd ~/src/custom-resources-tutorial cp ~/src/chef-cookbooks/docker/.gitignore . cp ~/src/chef-cookbooks/docker/.rubocop.yml .
rubocop -a git init git add . git commit -a
-m 'v0.0.1 - cookbook skeleton' git tag v0.0.1
Step 8 - Use resource in test recipe https://flic.kr/p/8MuUAX
emacs test/cookbooks/my_file_test/recipes/ default.rb
None
kitchen converge ; echo $?
Step 9 - Implement resource https://flic.kr/p/bkVKRb
cd ~/src/custom-resources-tutorial mkdir libraries emacs libraries/my_file.rb
None
kitchen converge ; echo $? kitchen converge ; echo $?
Step 10 - Test for behavior https://i.ytimg.com/vi/1y8Rqvz-Jcg/ maxresdefault.jpgz
mkdir -p test/integration/my_file/inspec emacs -p test/integration/my_file/inspec/ run_spec.rb
None
kitchen verify ; echo $?
Step 11 - Add specs and commit https://flic.kr/p/rrgfZh
cd ~/src/custom-resources-tutorial mkdir spec emacs spec/spec_helper.rb
None
emacs spec/my_file_spec.rb
None
rubocop -a rspec ; echo $? git add . git
commit -a -m “v0.1.0 - my_file resource” git tag v0.1.0
stove 0.1.0
Step 12 - Iterate indefinitely https://flic.kr/p/8Ny8Jt
Congratulations, you have now written one software.
You must now maintain it forever.
muahaha.
None
Part 2
Custom Resources Tips and Tricks
Be explicit https://flic.kr/p/pz1JAo
None
None
None
None
Converge twice during development Use markers for “negative” actions https://flic.kr/p/pqwd5U
None
None
Tests let you refactor with confidence https://flic.kr/p/4WnjM4
None
STAR WIPE
None
Pure Ruby resources https://flic.kr/p/5km2fM
Pure Ruby resources utilize - The Ruby Standard Library -
Chef helper libs (mixlib-shellout) - Ruby gems
None
It might make sense to vendor gems
load_current_value - Runs at converge time - Just before the
action body - Loads desired state values
None
converge_if_changed - Runs if any desired_state: true property differs from
user input - desired_state: false avoids comparison
None
coerce transforms values - Called when property is set -
Called when property is read - Use this to raise errors on bad input
The docker_container resource uses coercion heavily https://github.com/chef-cookbooks/ docker/blob/master/libraries/ docker_container.rb
lazy defaults - Delays evaluation until used - Useful for
calculated values
None
Composite resources https://flic.kr/p/fm58oo
Composite resources - Reuse Chef resources - Actions look like
recipes - Do not use load_current_value
etcd_installation_binary :create
httpd_config_rhel :create
Avoid leaky abstractions https://flic.kr/p/7d1kDc
Resources should be minimalist
Early versions might be simple
None
They rarely stay that way
Iterate and add more features Break down into smaller resources
Use naming semantics to describe strategy
etcd_installation_binary etcd_installation_docker etcd_installation_package etcd_service_manager_docker etcd_service_manager_execute etcd_service_manager_systemd etcd_service_manager_sysvinit etcd_service_manager_upstart
Recycle patterns as they emerge
docker_installation_binary docker_installation_package docker_installation_script docker_service_manager_execute docker_service_manager_systemd docker_service_manager_sysvinit docker_service_manager_upstart
Chef selects defaults with the provider resolution system
…
…
Compose resources Most specific to least specific
None
Enjoy
fin