厨师 - 制作 cookbook_file 的 yum localinstall
chef - making yum localinstall of cookbook_file
我有一些特定的 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
问题是 - 我如何绑定它们,以便在创建文件时调用安装?
简短的回答是 "use notifications" 但是当你谈到很多文件时,我会遍历这样一个列表:
['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
是在文件放置后立即启动包安装,如果有依赖项,您将必须管理包在数组中的顺序
我有一些特定的 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
问题是 - 我如何绑定它们,以便在创建文件时调用安装?
简短的回答是 "use notifications" 但是当你谈到很多文件时,我会遍历这样一个列表:
['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
是在文件放置后立即启动包安装,如果有依赖项,您将必须管理包在数组中的顺序