Multiple run_list items with knife? knife node run_list remove xyz.abc.org 'recipe'

How do I remove or add multiple roles / recipes with the knife node run_list [add/remove] command? I have looked through the wiki and experimented a bit and cannot figure out how to remove multiple roles or recipes in the same command.

Also, is there a way to remove all run_list items from the knife command line regardless of what roles or recipes are contained therein?

Thanks

Randy

Hi,

This currently can't be done, but based on this recent thread:

http://lists.opscode.com/sympa/arc/chef/2012-03/msg00115.html

a new patch has been submitted to provide this feature:

http://tickets.opscode.com/browse/CHEF-2968

Cheers,

Steve

On Tue, Mar 13, 2012 at 8:23 AM, Van Fossan,Randy vanfossr@oclc.org wrote:

How do I remove or add multiple roles / recipes with the knife node run_list
[add/remove] command? I have looked through the wiki and experimented a bit
and cannot figure out how to remove multiple roles or recipes in the same
command.

Also, is there a way to remove all run_list items from the knife command
line regardless of what roles or recipes are contained therein?

Thanks

Randy

That was discussed recently and the ticket is opened for that
http://tickets.opscode.com/browse/CHEF-1398

You can use knife exec until the fix gets merged

knife exec -E 'n=search(:node, "name:coolnode").first; n.run_list =
Chef::RunList.new("role[foo]", "role[bar]"); n.save'

--max

On Tue, Mar 13, 2012 at 8:23 AM, Van Fossan,Randy vanfossr@oclc.org wrote:

How do I remove or add multiple roles / recipes with the knife node
run_list [add/remove]
command? I have looked through the wiki and
experimented a bit and cannot figure out how to remove multiple roles or
recipes in the same command.****


Also, is there a way to remove all run_list items from the knife command
line regardless of what roles or recipes are contained therein?****


Thanks****

Randy ****

You can use knife exec until the fix gets merged

knife exec -E 'n=search(:node, "name:coolnode").first; n.run_list =
Chef::RunList.new("role[foo]", "role[bar]"); n.save'

Note that this will wipe out the existing run list entries. Something
like this may work, but it is a bit ugly:

knife exec -E 'n=nodes.show("NODENAME"); ["role[foo2]",
"role[bar2]"].each { |i| n.run_list << i }; n.save'

On Tue, Mar 13, 2012 at 3:44 PM, Steven Danna steve@opscode.com wrote:

You can use knife exec until the fix gets merged

knife exec -E 'n=search(:node, "name:coolnode").first; n.run_list =
Chef::RunList.new("role[foo]", "role[bar]"); n.save'

Note that this will wipe out the existing run list entries. Something
like this may work, but it is a bit ugly:

knife exec -E 'n=nodes.show("NODENAME"); ["role[foo2]",
"role[bar2]"].each { |i| n.run_list << i }; n.save'

Actually, the ticket was for adding more than one item to the
run_list, but there was no ticket about removing more than one item,
so I've added a ticket for that:
http://tickets.opscode.com/browse/CHEF-2976

I also added a pull-request with a posible implementation. I hope this
helps. Any feedback will be very welcome.
Thanks

--
Juanje