Hand Crafted Artisanal Chef Resources
-
Upload
sean-omeara -
Category
Technology
-
view
1.122 -
download
2
Transcript of Hand Crafted Artisanal Chef Resources
![Page 1: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/1.jpg)
Hand Crafted ArtisanalChef Resources
![Page 2: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/2.jpg)
Config Management CampGhent, BelgiumFebruary 2016
![Page 4: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/4.jpg)
whoami
![Page 5: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/5.jpg)
Part 1
![Page 6: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/6.jpg)
Writing library cookbooks An opinionated workflow Step by step
![Page 7: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/7.jpg)
Step 1 - Disregard dogma “Unit tests first” is a dirty lie
https://flic.kr/p/aTSiXF
![Page 9: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/9.jpg)
Contrived examples are the best examples
![Page 10: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/10.jpg)
![Page 11: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/11.jpg)
Place this off to the side, we will come back for it later.
![Page 13: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/13.jpg)
mkdir -p ~/src/custom-resources-tutorialcd ~/src/custom-resources-tutorialemacs metadata.rb
![Page 14: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/14.jpg)
![Page 15: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/15.jpg)
Step 4 - Embed a test cookbook. By hand. Be a wizard. Again.
https://flic.kr/p/ai36NG
![Page 16: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/16.jpg)
mkdir -p test/cookbooks/my_file_testcd test/cookbooks/my_file_testecho “test cookbook” > README.mdmkdir recipestouch recipes/default.rbemacs metadata.rb
![Page 17: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/17.jpg)
![Page 19: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/19.jpg)
cd ~/src/custom-resources-tutorialemacs Berksfile
![Page 20: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/20.jpg)
![Page 22: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/22.jpg)
emacs .kitchen.yml
![Page 23: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/23.jpg)
![Page 24: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/24.jpg)
kitchen test ; echo $?
![Page 26: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/26.jpg)
cd ~/src/custom-resources-tutorialcp ~/src/chef-cookbooks/docker/.gitignore .cp ~/src/chef-cookbooks/docker/.rubocop.yml .
![Page 27: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/27.jpg)
rubocop -agit initgit add .git commit -a -m 'v0.0.1 - cookbook skeleton' git tag v0.0.1
![Page 29: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/29.jpg)
emacs test/cookbooks/my_file_test/recipes/default.rb
![Page 30: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/30.jpg)
![Page 31: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/31.jpg)
kitchen converge ; echo $?
![Page 33: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/33.jpg)
cd ~/src/custom-resources-tutorialmkdir librariesemacs libraries/my_file.rb
![Page 34: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/34.jpg)
![Page 35: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/35.jpg)
kitchen converge ; echo $?kitchen converge ; echo $?
![Page 36: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/36.jpg)
Step 10 - Test for behavior
https://i.ytimg.com/vi/1y8Rqvz-Jcg/maxresdefault.jpgz
![Page 37: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/37.jpg)
mkdir -p test/integration/my_file/inspecemacs -p test/integration/my_file/inspec/run_spec.rb
![Page 38: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/38.jpg)
![Page 39: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/39.jpg)
kitchen verify ; echo $?
![Page 41: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/41.jpg)
cd ~/src/custom-resources-tutorialmkdir specemacs spec/spec_helper.rb
![Page 42: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/42.jpg)
![Page 43: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/43.jpg)
emacs spec/my_file_spec.rb
![Page 44: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/44.jpg)
![Page 45: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/45.jpg)
rubocop -arspec ; echo $?git add .git commit -a -m “v0.1.0 - my_file resource”git tag v0.1.0
![Page 46: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/46.jpg)
stove 0.1.0
![Page 48: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/48.jpg)
Congratulations, you have now written one software.
![Page 49: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/49.jpg)
You must now maintain it forever.
![Page 50: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/50.jpg)
muahaha.
![Page 51: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/51.jpg)
![Page 52: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/52.jpg)
Part 2
![Page 53: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/53.jpg)
Custom Resources Tips and Tricks
![Page 55: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/55.jpg)
![Page 56: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/56.jpg)
![Page 57: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/57.jpg)
![Page 58: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/58.jpg)
![Page 59: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/59.jpg)
Converge twice during development Use markers for “negative” actions
https://flic.kr/p/pqwd5U
![Page 60: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/60.jpg)
![Page 61: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/61.jpg)
![Page 63: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/63.jpg)
![Page 64: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/64.jpg)
STAR WIPE
![Page 65: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/65.jpg)
![Page 67: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/67.jpg)
Pure Ruby resources utilize
- The Ruby Standard Library - Chef helper libs (mixlib-shellout) - Ruby gems
![Page 68: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/68.jpg)
![Page 69: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/69.jpg)
It might make sense to vendor gems
![Page 70: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/70.jpg)
load_current_value
- Runs at converge time - Just before the action body - Loads desired state values
![Page 71: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/71.jpg)
![Page 72: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/72.jpg)
converge_if_changed
- Runs if any desired_state: true property differs from user input
- desired_state: false avoids comparison
![Page 73: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/73.jpg)
![Page 74: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/74.jpg)
coerce transforms values
- Called when property is set - Called when property is read - Use this to raise errors on bad input
![Page 75: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/75.jpg)
The docker_container resource uses coercion heavily
https://github.com/chef-cookbooks/docker/blob/master/libraries/docker_container.rb
![Page 76: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/76.jpg)
lazy defaults
- Delays evaluation until used - Useful for calculated values
![Page 77: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/77.jpg)
![Page 79: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/79.jpg)
Composite resources
- Reuse Chef resources - Actions look like recipes - Do not use load_current_value
![Page 80: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/80.jpg)
etcd_installation_binary :create
![Page 81: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/81.jpg)
httpd_config_rhel :create
![Page 83: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/83.jpg)
Resources should be minimalist
![Page 84: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/84.jpg)
Early versions might be simple
![Page 85: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/85.jpg)
![Page 86: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/86.jpg)
They rarely stay that way
![Page 87: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/87.jpg)
Iterate and add more features Break down into smaller resources
![Page 88: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/88.jpg)
Use naming semantics to describe strategy
![Page 89: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/89.jpg)
etcd_installation_binaryetcd_installation_dockeretcd_installation_package
etcd_service_manager_dockeretcd_service_manager_executeetcd_service_manager_systemdetcd_service_manager_sysvinitetcd_service_manager_upstart
![Page 90: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/90.jpg)
Recycle patterns as they emerge
![Page 91: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/91.jpg)
docker_installation_binarydocker_installation_packagedocker_installation_script
docker_service_manager_executedocker_service_manager_systemddocker_service_manager_sysvinitdocker_service_manager_upstart
![Page 92: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/92.jpg)
Chef selects defaults with the provider resolution system
![Page 93: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/93.jpg)
…
![Page 94: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/94.jpg)
…
![Page 95: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/95.jpg)
Compose resources Most specific to least specific
![Page 96: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/96.jpg)
![Page 97: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/97.jpg)
Enjoy
![Page 98: Hand Crafted Artisanal Chef Resources](https://reader033.fdocuments.in/reader033/viewer/2022051502/586ff6bc1a28ab92198b74c9/html5/thumbnails/98.jpg)
fin