我有一些特定的rpm需要移动到一个盒子,并且yum localinstall在那里。
现在我知道如何在文件创建时使notifies
yum会从repo安装一些东西,但在这种情况下我不知道如何指定源。
所以现在,我有以下内容:
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
问题是 - 如何绑定它们,以便在创建文件时调用安装?
答案 0 :(得分:1)
简短的回答是“使用通知”但是当你谈论很多文件时,我会循环遍历这样的列表:
['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
:immediately
是在文件放置后立即触发软件包安装,如果存在依赖关系,则必须管理数组中软件包的顺序