git_to_chef - Yet another workflow

I've written a script (and cookbook to deploy it) to handle our current workflow with Chef using Git.

git_to_chef will compare the Chef cookbooks in Git to those in a Chef Environment. If there are new and/or updated cookbooks in Git, it'll either log it or upload/freeze the affected cookbooks, update the stated environment, upload databags, upload roles then send an email notification. Note, if you run as an upload, it will upload all data bags and roles no matter the status of cookbooks.

The Chef workflow that's currently working for us is:

  • Edit cookbooks, etc. in a non-master branch in Git
  • Test in a non-production environment
  • Commit/Push changes
  • Send a Pull Request and collaborate
  • Edit/test more, if needed
  • Merge the Pull Request to Master
  • Manually run git_to_push as an upload that will:
    • Pull from Git
    • Upload new(er) cookbooks
    • Freeze new(er) cookbooks
    • Update the Production environment with the cookbook versions from Git
    • Graph the upload in Graphite
    • Upload ALL databags from Git
    • Upload ALL roles from Git
    • Send an email notification of the proceedings
  • git_to_push runs hourly in report mode to nag us of changes that haven't
    been uploaded to Chef

I'm relatively new to Ruby/Chef/Git, any input is appreciated.


1 Like