Knife exec changes from chef 10 to 11?


#1

I’ve been using a command similar to this for a while in chef 10, but now
in chef 11 it no longer works:

knife exec -E’nodes.find(:name => “testnode.here.com”) {|n| puts
n.sudo.additional_sudoers([“blah”,“blah”,“blah”,]);n.save’}

Is there a new way to set attributes from knife exec? I had a script that
I would use to create this command and its not working for me anymore. Any
suggestions?

Error message:

ERROR: knife encountered an unexpected error
This may be a bug in the ‘exec’ knife command or plugin
Please collect the output of this command with the -VV option before
filing a bug report.
Exception: NoMethodError: Undefined node attribute or method
additional_sudoers' onnode’
shillinm@cwsdev02exdu:~/chefsy01exdu$

I am sure the attribute exists:
knife node show testnode.here.com -a sudo
testnode.here.com:
sudo:
additional_sudoers:
sudoers:

Thanks in advance

Mike


#2

check out:

you want:

n.default[“sudo”][“additional_sudoers”] = [ “blah”,“blah”,“blah”]

On 1/17/14 12:50 PM, Mike wrote:

I’ve been using a command similar to this for a while in chef 10, but
now in chef 11 it no longer works:

knife exec -E’nodes.find(:name => “testnode.here.com
http://testnode.here.com”) {|n| puts
n.sudo.additional_sudoers([“blah”,“blah”,“blah”,]);n.save’}

Is there a new way to set attributes from knife exec? I had a script
that I would use to create this command and its not working for me
anymore. Any suggestions?

Error message:

ERROR: knife encountered an unexpected error
This may be a bug in the ‘exec’ knife command or plugin
Please collect the output of this command with the -VV option before
filing a bug report.
Exception: NoMethodError: Undefined node attribute or method
additional_sudoers' onnode’
shillinm@cwsdev02exdu:~/chefsy01exdu$

I am sure the attribute exists:
knife node show testnode.here.com http://testnode.here.com -a sudo
testnode.here.com http://testnode.here.com:
sudo:
additional_sudoers:
sudoers:

Thanks in advance

Mike


#3

It’s a change to make the attributes API less error-prone, see http://www.getchef.com/blog/2013/02/05/chef-11-in-depth-attributes-changes/


Daniel DeLeo

On Friday, January 17, 2014 at 12:50 PM, Mike wrote:

I’ve been using a command similar to this for a while in chef 10, but now in chef 11 it no longer works:

knife exec -E’nodes.find(:name => “testnode.here.com (http://testnode.here.com)”) {|n| puts n.sudo.additional_sudoers([“blah”,“blah”,“blah”,]);n.save’}

Is there a new way to set attributes from knife exec? I had a script that I would use to create this command and its not working for me anymore. Any suggestions?

Error message:

ERROR: knife encountered an unexpected error
This may be a bug in the ‘exec’ knife command or plugin
Please collect the output of this command with the -VV option before filing a bug report.
Exception: NoMethodError: Undefined node attribute or method additional_sudoers' onnode’
shillinm@cwsdev02exdu:~/chefsy01exdu$

I am sure the attribute exists:
knife node show testnode.here.com (http://testnode.here.com) -a sudo
testnode.here.com (http://testnode.here.com):
sudo:
additional_sudoers:
sudoers:

Thanks in advance

Mike