Hi there, Chef noob here. I’m looking into using Chef to deploy our builds to Chef node servers (Windows Server 2012 machines). I have a cookbook called copy_builds that goes out to a central repository and selects the build we want to deploy and copies it out to the node server. The recipe I have contains basic and generic steps that perform the copy steps, and this recipe could be used for all builds we want to deploy except for one thing: the build name.
Here is an example of the recipe:
powershell_script 'Copy build files' do code ' $Project = "Dev3_SomeCoolBuild" net use "\\\\server\\build_share\\drop\\$Project" $BuildNum = GC "\\\\server\\build_share\\drop\\$Project\\buildlabel.txt" robocopy \\\\server\\build_share\\drop\\$Project\\webbin W:\\binroot\\$BuildNum' end
As you can see, the variable $Project contains the name of the build in this recipe. If we have 100 different builds, all with different names, then what is the best way to handle this without creating 100 different recipes for my copy_builds cookbook?
BTW: this is how I’m currently calling Chef to deploy:
knife node run_list set $Node "recipe[copy_builds::$ProjectName],recipe[install_build]"
This command is in a PowerShell script and contains the $Project name info within it’s own $ProjectName variable. In this case $ProjectName contains the value of ‘Dev3_SomeCoolBuild’, to reference the recipe Dev3_SomeCoolBuild.rb.
What I’d like to do is have just one default recipe under copy_builds cookbook, and pass in the build name. Is this possible? And what is the best way to do it? I’ve read about data bags and attributes, but not sure if they would work for what I want.