- From: Ravindra <
>
- To:
- Subject: [chef] Chef Recipe Help
- Date: Wed, 30 Oct 2013 04:23:16 -0700 (PDT)
Hello,
I'm learning Chef and need help in below mentioned scenario.
Here is the Chef recipe that I'm using.
in attributes/default.rb file
node['my_recipe']['sample'] = {'tool1' => ['toolname', 'tool1.exe',
'/sc Weekly /d SUN /st 1:00]}
#global variable
$schedule_name=''
$executable =''
$schedule = ''
node['my_recipe']['sample'].each do |tool, infoList|
ruby_block "assign_variable" do
block do
$schedule_name = infoList.at(0)
$executable = infoList.at(1)
$schedule = infoList.at(2)
puts "schedule_name = #{$schedule_name}"
puts "executable = #{$executable}"
puts "schedule = #{$schedule}"
end
action :create
notifies :run, "execute[schedule_#{tool}]"
end
ruby_block "display_variable" do
block do
puts "schedule_name = #{$schedule_name}"
puts "executable = #{$executable}"
puts "schedule = #{$schedule}"
end
end
execute "schedule_#{tool}" do
command "schtasks /create /tn \"#{$schedule_name}\" /tr
\"#{node['my_recipe']['tools_dir']}\\#{tool}\\#{$executable}\"
#{$schedule}"
action :nothing
end
end
In "ruby_block "assign_variable" do", I'm asigning values to global variable.
In "ruby_block "display_variable" do", I'm able to fetch the values of
these variables successfully.
However, in "execute "schedule_#{tool}" do", when I'm using these
global variable it returns me empty.
Could you please assist me resolving me?
Regards,
Ravindra Chandrakar
- [chef] Chef Recipe Help, Ravindra, 10/30/2013
Archive powered by MHonArc 2.6.16.