Search code examples
chef-infrachef-recipecookbook

knife add role to node only if role exists


I don't like the default behavior of this command:

knife node run_list add myserver '"role[THISISATEST]"'

It adds THIISATEST even if the role doesn't exists. Is there a switch or argument that will prevent knife from adding a role/recipe to a node if it does not exist?


Solution

  • You would probably do this with a knife exec script of some form, but it's hard to know exactly what code to use without more information.