问题
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.
Just need a chef way for rpm -i.
回答1:
You have two options:
Bash it
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
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
This will iterate over each item in the given path that matches the glob.
来源:https://stackoverflow.com/questions/22913065/installing-rpm-packages-using-chef-with-dependencies