women's do it yourself: vagrant chef workshop [jan 24 2015]
TRANSCRIPT
Let’s Start With the Basics
- recipes are made of resources and applied to nodes
- today we will focus on cookbooks and recipes
Anatomy of a Resource
- type, name, action, attribute
- where do they come from?
- built into chef (package, service, directory, template, etc.)
- provided by community cookbooks (ruby_build, web_app, etc.)
- written by you!
Descriptive Not Prescriptive
- recipes should be idempotent
- recipes should be platform independent
- nodes “converge”
- chef won’t prevent you from doing it wrong
Good
Bad
Worse
Provider
- Implements resources
- Provider figures out what actions to take for
different platforms. (e.g. for a package should I
use apt, yum, or something else?)
- Figures out what (if anything) to do based on
current state
Attributes
- specific detail about a node
- allow for configurability
- come from many different places
- ohai
- environment
- cookbook
- role
- node definition
- chef has complicated order of attribute precedence
- you can use knife (a chef command line tool) to inspect attributes for a
given node
Borrow From The Community
- Always use community cookbook when possible!
- Most things you want to do have already been done (e.g. tomcat, mysql, apache)
- If you need to make modifications create a wrapper cookbook
- There are 2 main ways to borrow from the community, include a recipe or use a custom
resources
Chef Developer Tools
- Berkshelf (dependency
manager)
- Test-Kitchen (‘integration
tool for developing and
testing cookbooks’)