问题
I want to run a set of generic cookbooks that will a user-selected version of our product in our lab, and want to use jenkins to do this. What is the best way for my Jenkins job to pass this information during the node bootstrap? Is it via the -j option, for example -j '{"load_version" : "$LOAD_VERSION"}', where $LOAD_VERSION is a parameter of the Jenins job with several choices?
回答1:
Yes, -j
will let you supply a JSON blob of attributes to the first chef-client run of your recipes.
It's generally best to add scope to your node attributes so if you expand things you have less chance of clashing with other attributes.
knife bootstrap <host> -r 'recipe[your_cb::your_recipe]' -j '{ "your_cb": { "load_version": "$LOAD_VERSION" } }'
来源:https://stackoverflow.com/questions/25750087/how-to-set-chef-attributes-via-jenkins