[chef] how can i set node attribute from inside powershell_script resource


Chronological Thread 
  • From: Pradeep Kumar < >
  • To:
  • Subject: [chef] how can i set node attribute from inside powershell_script resource
  • Date: Fri, 10 Jul 2015 19:37:05 +0530

Hi All,

i have a boolean attribute. i want to set the attribute to true conditionally inside a powershell_script.
if the attribute is true i would like to throw a fatal error message and abort chef run.

i'm stuck on how to set the attribute value from inside the powershell.

in the below case #{node.default['saas_wfa_prod_db_server']['fail_chef']=true} is running irrespective of the if condition. (may be its evaluated during compile) 

below is the code. can some one please help.


--code--
node.default['saas_wfa_prod_db_server']['fail_chef'] = false

powershell_script "get available offline disks" do
code <<-EOH
$sysstoragelength =4
$drivestoragelength=5

if($sysstoragelength -lt $drivestoragelength)
{
#{node.default['saas_wfa_prod_db_server']['fail_chef']=true}
}
EOH
end


if (node['saas_wfa_prod_db_server']['fail_chef']) 
Chef::Application.fatal!("sufficient number of disks not available in offline state", 42) 
end


--
pradeep



Archive powered by MHonArc 2.6.16.

§