So, I’ve done some searching through the documents, and searching through the archives, and feeding various terms into Google, and I’m still coming up empty.
In short, I know that I could do a “knife node run_list add” from within a recipe, but I figure there has to be a better way to do this from within Ruby itself, and which doesn’t involve dependency on a tool that shouldn’t have to be installed on every single node that might run some random application.
I must be missing something obvious, but I don’t know what it is. Any and all assistance or pointers you can provide will be greatly appreciated.
Why not just key off an attribute to decide whether or not to do recipe_includes? Here’s an example:
You could wrap that in any sort of conditional Ruby logic you want.
Thanks,
Matt Ray
Cloud Integrations Product Lead :: Opscode
512.731.2218 :: matt@opscode.com
mattray :: GitHub :: IRC :: Twitter
From: Brad Knowles brad@shub-internet.org
Sent: Tuesday, August 27, 2013 9:05 AM
To: chef@lists.opscode.com
Cc: Brad Knowles
Subject: [chef] Modifying node run list from within a recipe?
Folks,
So, I’ve done some searching through the documents, and searching through the archives, and feeding various terms into Google, and I’m still coming up empty.
In short, I know that I could do a “knife node run_list add” from within a recipe, but I figure there has to be a better way to do this from within Ruby itself, and which doesn’t involve dependency on a tool that shouldn’t have to be installed on every single node that might run some random application.
I must be missing something obvious, but I don’t know what it is. Any and all assistance or pointers you can provide will be greatly appreciated.
You could wrap that in any sort of conditional Ruby logic you want.
In the particular case I have, I'm converting an installation script from bash to Chef, and part of what the bash script does is adding a role to the run_list for the node it's running on. So, the Chef recipe(s) in question would be running as a command-line over-ride for the node, possibly as part of a chef-solo run, and not part of a normal chef-client run.
So, unless there's something obvious that I'm missing, I don't have a way to modify the existing Chef recipe(s) for the node to do the kind of thing that you're suggesting.
In the particular case I have, I'm converting an installation script from bash to Chef, and part of what the bash script does is adding a role to the run_list for the node it's running on. So, the Chef recipe(s) in question would be running as a command-line over-ride for the node, possibly as part of a chef-solo run, and not part of a normal chef-client run.
Ahh, it just took a bit more searching. The end result is shown at [0], but the key elements were discovering that the class is Chef::RunList::RunListItem (I found good examples at [1] and [2]), but the key link is shown at [3]: