Install chef gem (for knife
command):
gem install chef
knife cookbook create my_cookbook
This generates a skeleton cookbook locally.
After you make a change to a cookbook, be sure to bump the version number in
cookbooks/my_cookbook/metadata.rb
. That way you can test your changes on
ad-hoc environments before staging & production.
When you're ready to run your cookbook on ad-hoc environments, run:
knife cookbook upload my_cookbook
This makes the chef server aware of your changes.
When you're comfortable with your changes, commit & push them to git.
Upload the cookbook one more time with the --freeze option to prevent others from overwriting it:
knife cookbook upload my_cookbook --freeze
Edit environments/staging.rb
to use your new cookbook version.
Upload the environment to the chef server:
knife environment from file staging.rb
Once you've checked that the new cookbook works well on staging, upgrade
environments/production.rb
similarly.
In git, commit & push your changes to the environments files.