Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

download roles and cookbooks from ChefServer with knife

Given I started working with Chef using the Chef Server Management Console and I now want to start using a files and upload them via knife. Is there a way to retrive roles and environments that are stored on the ChefServer via knife, so I can them into git?

like image 314
Michael Küller Avatar asked May 25 '12 14:05

Michael Küller


1 Answers

You can use the knife environment list and knife environment show commands to download environments and replace "environment" with "role" to do the same for roles.

mkdir environments
for env in `knife environment list`; do
  knife environment show $env --format=json > environments/$env.json
done

You can then check these JSON files into git and edit/upload with knife.

like image 63
Tim Potter Avatar answered Sep 27 '22 18:09

Tim Potter