使用Chef安装rpm软件包(带有依赖项) [英] Installing rpm packages using chef (with dependencies)
问题描述
我有一个rpm软件包列表,包括依赖项。我在本地执行rpm -i * .rpm,它工作正常。使用厨师的rpm_package资源时,如何使用-i标志。我无法使用yum,因为我们正在尝试离线工作。
I have a list of rpm packages including dependencies. Locally I do rpm -i *.rpm and it works fine. How do I use the -i flag when I use chef's rpm_package resource. I cant use yum as we are trying something that works offline.
只需要一种厨师方式来实现rpm -i。
Just need a chef way for rpm -i.
推荐答案
您有两种选择:
就像您在问题中所做的一样,您可以使用 bash
资源来执行rpm命令。默认情况下,这不是等幂的,并且(显然)不是跨平台的:
Just like you did in your question, you can use the bash
resource to execute the rpm command. This is not idempotent by default and is (obviously) not cross-platform:
bash 'rpm -i *.rpm' do
cwd '/path/to/that/directory'
end
Ruby it
不太直接,可以使用Ruby的本机文件系统功能遍历树:
Ruby it
Slightly less straightforward, you can use Ruby's native file system functions to traverse the tree:
Dir['/path/to/rpms/*.rpm'].each do |path|
rpm_package File.basename(path) do
source path
end
end
这将遍历给定路径中与glob相匹配的每个项目。
This will iterate over each item in the given path that matches the glob.
这篇关于使用Chef安装rpm软件包(带有依赖项)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!