I feel like this has been asked before, but I can’t seem to find the answer I am looking for, or in fact an answer (even if it isn’t what I want to hear).
I have a cookbook that does organisation specific config of our nodes during bootstrap. I am wanting to know if there is a way to supply a one time runlist during bootstrap so that the initial runlist specified isn’t permanent? I see there used to be a -o option that could be used as an override, but the knife bootstrap command doesn’t like this anymore
This won't work. knife will successfully edit the node, but then when the in-progress Chef Client run completes, it will save the node and overwrite what knife did.
What you want to do instead is modify the run list on the node object in Chef Client so that the run list you want gets saved by Chef at the end of the run. The basic code is node.run_list("recipe[foo::bar]", "recipe[baz::qux]", ...) though you may need to stuff that in a ruby block resource to get the compile time/converge time stuff right, depending on how you compute the run list.
Thanks for that. Here is what I ended up doing, just incase another noob (like me) requires a more full answer:
# Removes the recipe 'my_recipe' from the nodes run list
ruby_block 'remove_my_recipe' do
block do
node.run_list.remove('recipe[my_recipe]')
end
action :run
end