Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hand Crafted Artisinal Chef Resources

February 02, 2016

Hand Crafted Artisinal Chef Resources

Configuration Management Camp
Ghent Belgium
February 2016


February 02, 2016

More Decks by someara

Other Decks in Technology


  1. Step 1 - Disregard dogma “Unit tests first” is a

    dirty lie https://flic.kr/p/aTSiXF
  2. Step 3 - Create a cookbook By hand. Be a

    wizard. https://flic.kr/p/3mMW6e
  3. Step 4 - Embed a test cookbook. By hand. Be

    a wizard. Again. https://flic.kr/p/ai36NG
  4. rubocop -a git init git add . git commit -a

    -m 'v0.0.1 - cookbook skeleton' git tag v0.0.1
  5. rubocop -a rspec ; echo $? git add . git

    commit -a -m “v0.1.0 - my_file resource” git tag v0.1.0
  6. Pure Ruby resources utilize - The Ruby Standard Library -

    Chef helper libs (mixlib-shellout) - Ruby gems
  7. load_current_value - Runs at converge time - Just before the

    action body - Loads desired state values
  8. converge_if_changed - Runs if any desired_state: true property differs from

    user input - desired_state: false avoids comparison
  9. coerce transforms values - Called when property is set -

    Called when property is read - Use this to raise errors on bad input
  10. Composite resources - Reuse Chef resources - Actions look like

    recipes - Do not use load_current_value