我有一些特定的rpm,需要移动到一个盒子,并在那里安装百胜。
现在我知道如何使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问题是-如何绑定它们,以便在文件创建时调用安装?
发布于 2015-02-18 13:01:11
简单的回答是“使用通知”,但是当您谈到许多文件时,我会循环如下列表:
['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将在文件放置后立即启动包安装,如果存在依赖项,则必须管理数组中包的顺序
https://stackoverflow.com/questions/28581705
复制相似问题