Issue
I have some certain rpm's that need to be moved to a box, and yum localinstall'ed there.
Now I know how to make notifies
for upon file creation yum would install something from repo, but I don't know how to specify source in this case.
So for now, I have the following:
cookbook_file "mksh-39-5.el6.x86_64.rpm" do
path "/tmp/mksh-39-5.el6.x86_64.rpm"
action :create
end
package "mksh-39-5.el6.x86_64.rpm" do
source "/tmp/mksh-39-5.el6.x86_64.rpm"
action :install
end
The question is - how do I bind them, so that installation would be called upon file creation?
Solution
The brief answer is "use notifications" but as you talk about many files I would loop over a list like this:
['mksh-39-5.el6.x86_64.rpm','package2.rpm'].each do |p| # start from an array of packages, could be an attributes like node['my_namespace']['packages']
package p do # no need to do interpolation here, we just need the name
source "/tmp/#{p}" # Here we have to concatenate path and name
action :nothing # do nothing, just define the resource
end
cookbook_file "/tmp/#{p}" do # I prefer setting the destination in the name
source p # and tell the source name, so in case of different platfom I can take advantage of the resolution of files withint the cookbook tree
action :create
notifies :install, "package[/tmp/#{p}]", :immediately
end
end
The :immediately
is to fire the package install as soon as the file has been placed, if there's dependencies, you'll have to manage the order of the packages in the array
Answered By - Tensibai Answer Checked By - Pedro (WPSolving Volunteer)