Installing rpm packages using chef (with dependencies)

女生的网名这么多〃 提交于 2019-12-11 11:08:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!