[chef] Re: Re: Getting grouped attributes with node.attribute?


Chronological Thread 
  • From: Christian Fröstl < >
  • To: " " < >
  • Subject: [chef] Re: Re: Getting grouped attributes with node.attribute?
  • Date: Mon, 14 Apr 2014 11:54:35 +0000
  • Accept-language: de-DE, en-US

Hi Tensibai,

It works well. Thank you very much.



Le 2014-04-14 13:04, Christian Fröstl a écrit :

Hi there,
 
I try to do a only once command within a chef recipe which looks like the following:
 
execute "register_spacewalk" do
command "rhnreg_ks --serverUrl=http://spw0002.adm.nubon.com/XMLRPC --activationkey=1-d5ecd39c881c8202fd82f7bc930178be --force"
notifies :create, "ruby_block[register_spacewalk_run_flag]", :immediately
not_if { node.attribute?("register_spacewalk_run_flag") }
end
 
ruby_block "register_spacewalk_run_flag" do
block do
node.set["register_spacewalk_run_flag"] = true
node.save
end
action :nothing
End
 
The above command works fine, but I like to group all my spacewalk attribute variables under the group spacewalk. 
For this, i tried to do the following:
 
execute "register_spacewalk" do
command "rhnreg_ks --serverUrl=http://spw0002.adm.nubon.com/XMLRPC --activationkey=1-d5ecd39c881c8202fd82f7bc930178be --force"
notifies :create, "ruby_block[register_spacewalk_run_flag]", :immediately
not_if { node.attribute?("spacewalk""register_spacewalk_run_flag") }
end
 
ruby_block "register_spacewalk_run_flag" do
block do
node.set["spacewalk"]["register_spacewalk_run_flag"] = true
node.save
end
action :nothing
End
 
The node.set command works well, but I cannot do the node.attribute? Method on this attribute. I tried it with many different syntax like („spacewalk:register_spacewalk_run_flag“)  or („spacewalk register_spacewalk_run_flag“)  or (["spacewalk“]["register_spacewalk_run_flag"])  or  ("[spacewalk]“"[register_spacewalk_run_flag]“)
 
Do you have any idea how to solve the problem?
 
Thank you very much.
 
Greetings,
Kasimir

Hi,

You should try:

not_if { node.attribute?("spacewalk") && node['spacewalk'].attribute?("register_spacewalk_run_flag") }

ruby evaluate from left to right, it will stop at first false found.

 

Regards,

Tensibai

 



Archive powered by MHonArc 2.6.16.

§