This is very strange. Am I doing something that can’t be accomplished
with knife exec?
it works perfectly when I run it from shef on my workstation
usage knife exec ./change_env.rb query environment_name
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
my_nodes = search(:node, “#{query}”)
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
I tried the work around on this ticket
http://tickets.opscode.com/browse/CHEF-1910
nodes.transform("name:NODE_NAME") {|n| n.chef_environment = "ENVIRONMENT"}
but still no joy
On Mon, Jan 9, 2012 at 1:39 PM, Bryan Berry bryan.berry@gmail.com wrote:
This is very strange. Am I doing something that can't be accomplished
with knife exec?
it works perfectly when I run it from shef on my workstation
usage knife exec ./change_env.rb query environment_name
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
my_nodes = search(:node, "#{query}")
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
query=ARGV[2]
new_environment=ARGV[3]
?
On Mon, Jan 9, 2012 at 6:09 PM, Bryan Berry bryan.berry@gmail.com wrote:
This is very strange. Am I doing something that can't be accomplished
with knife exec?
it works perfectly when I run it from shef on my workstation
usage knife exec ./change_env.rb query environment_name
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
my_nodes = search(:node, "#{query}")
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
I hard code those values when i use them in shef
On Mon, Jan 9, 2012 at 2:42 PM, Ranjib Dey ranjibd@thoughtworks.com wrote:
query=ARGV[2]
new_environment=ARGV[3]
?
On Mon, Jan 9, 2012 at 6:09 PM, Bryan Berry bryan.berry@gmail.com wrote:
This is very strange. Am I doing something that can't be accomplished
with knife exec?
it works perfectly when I run it from shef on my workstation
usage knife exec ./change_env.rb query environment_name
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
my_nodes = search(:node, "#{query}")
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
sorry misunderstood your question, ARGV[0] and ARGV[1] are correct. I
guess that knife exec shifts the opts when it passes them to the
script
On Mon, Jan 9, 2012 at 2:44 PM, Bryan Berry bryan.berry@gmail.com wrote:
I hard code those values when i use them in shef
On Mon, Jan 9, 2012 at 2:42 PM, Ranjib Dey ranjibd@thoughtworks.com wrote:
query=ARGV[2]
new_environment=ARGV[3]
?
On Mon, Jan 9, 2012 at 6:09 PM, Bryan Berry bryan.berry@gmail.com wrote:
This is very strange. Am I doing something that can't be accomplished
with knife exec?
it works perfectly when I run it from shef on my workstation
usage knife exec ./change_env.rb query environment_name
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
my_nodes = search(:node, "#{query}")
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
Hi,
On Mon, Jan 9, 2012 at 4:39 AM, Bryan Berry bryan.berry@gmail.com wrote:
This is very strange. Am I doing something that can't be accomplished
with knife exec?
Do you get any error messages? How are you determining that the
environment isn't being changed?
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
On recent versions of Chef, this should be ARGV[2] and ARGV[3] as Ranjib said.
my_nodes = search(:node, "#{query}")
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
I tested this basic script using Chef 0.10.8 and it worked as far as I
could tell.
Cheers,
Steven
hmm,
I see no error messages, none at all. I will look at this again
tks Steve
On Mon, Jan 9, 2012 at 4:36 PM, Steven Danna steve@opscode.com wrote:
Hi,
On Mon, Jan 9, 2012 at 4:39 AM, Bryan Berry bryan.berry@gmail.com wrote:
This is very strange. Am I doing something that can't be accomplished
with knife exec?
Do you get any error messages? How are you determining that the
environment isn't being changed?
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
On recent versions of Chef, this should be ARGV[2] and ARGV[3] as Ranjib said.
my_nodes = search(:node, "#{query}")
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
I tested this basic script using Chef 0.10.8 and it worked as far as I
could tell.
Cheers,
Steven
hmm, i think it works now, u guys were right about the arguments, I
missed that in the midst of multitasking confusion. tks for taking
the time to test it.
On Mon, Jan 9, 2012 at 4:38 PM, Bryan Berry bryan.berry@gmail.com wrote:
hmm,
I see no error messages, none at all. I will look at this again
tks Steve
On Mon, Jan 9, 2012 at 4:36 PM, Steven Danna steve@opscode.com wrote:
Hi,
On Mon, Jan 9, 2012 at 4:39 AM, Bryan Berry bryan.berry@gmail.com wrote:
This is very strange. Am I doing something that can't be accomplished
with knife exec?
Do you get any error messages? How are you determining that the
environment isn't being changed?
query = ARGV[0] # i type this in when using shef
new_environment = ARGV[1]
On recent versions of Chef, this should be ARGV[2] and ARGV[3] as Ranjib said.
my_nodes = search(:node, "#{query}")
my_nodes.each do |n|
n.chef_environment new_environment
n.save
end
exit 0
I tested this basic script using Chef 0.10.8 and it worked as far as I
could tell.
Cheers,
Steven