[chef] Issue with changing nodes run_list from command line using "knife exec -E"


Chronological Thread 
  • From:
  • To:
  • Subject: [chef] Issue with changing nodes run_list from command line using "knife exec -E"
  • Date: Mon, 05 Jan 2015 14:55:40 +0200

Hi guys,

What I need is to change nodes run_list basing on their tags and roles and names etc. 

For example I have multiple nodes with different roles etc.

And I would like to assign some particular recipe to nodes which met some condition:

knife exec -E "nodes.find(:name => '*isec*') { |node| node.run_list << "recipe[foo]"; n.save }"

It will work for nodes which have *isec* in its names. 


But what if I would like to use query something like:

knife exec -E "nodes.find(:name => '*isec*' AND :tags => 'tag_name' AND :role => 'role_name') { |node| node.run_list << "recipe[foo]"; n.save }"

It fails. As it seems that "nodes.find" method only can take 1 statement. And right after first statement it is looking for ')' instead of AND or other things... 
Or at least I have not found other usage. 

Can you please help me with this issue?

Many thanks in advance. 

Regards,
Taras.



Archive powered by MHonArc 2.6.16.

§