我正在尝试使用yum_package来安装存储在root / gpfs_driver路径下的基目录中的rpm文件
%w("gpfs.*.*.rpm").each do |pkg|
package "#{pkg}" do
source "/root/gpfs_drive/base/"
action :install
end
end
错误:
Compiled Resource:
------------------
# Declared in /root/.chef/local-mode-cache/cache/cookbooks/preq/recipes/test.rb:2:in `block in from_file'
yum_package(""gpfs.*.*.rpm"") do
package_name "\"gpfs.*.*.rpm\""
action [:install]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :package
cookbook_name "preq"
recipe_name "test"
source "/root/gpfs_drive/base/"
flush_cache {:before=>false, :after=>false}
end
System Info:
------------
chef_version=12.21.3
platform=redhat
platform_version=7.2
ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
program_name=chef-client worker: ppid=23043;start=17:09:14;
executable=/opt/chef/bin/chef-client
[2018-04-13T17:09:19+10:00] INFO: Running queued delayed notifications before re-raising exception
Running handlers:
[2018-04-13T17:09:19+10:00] ERROR: Running exception handlers Running handlers complete
[2018-04-13T17:09:19+10:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated in 04 seconds
[2018-04-13T17:09:19+10:00] FATAL: Stacktrace dumped to /root/.chef/local-mode-cache/cache/chef-stacktrace.out
[2018-04-13T17:09:19+10:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-04-13T17:09:19+10:00] ERROR: yum_package["gpfs.*.*.rpm"] (preq::test line 2) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE} %{ARCH} ' /root/gpfs_drive/base/ ---- STDOUT: STDERR: error: open of /root/gpfs_drive/base/ failed: No such file or directory
---- End output of rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE} %{ARCH} ' /root/gpfs_drive/base/ ---- Ran rpm
-qp --queryformat '%{NAME} %{VERSION}-%{RELEASE} %{ARCH} ' /root/gpfs_drive/base/ returned 1
答案 0 :(得分:0)
厨师不会这样做。
首先,%w("gpfs.*.*.rpm")
不会列出目录中的所有包。它只是数组的别名。你应该做Dir.glob("/root/gpfs_drive/base/gpfs.*.*.rpm")
。
然后你必须在source
。
从头到尾:
Dir.glob("/root/gpfs_drive/base/gpfs*.rpm").each do |pkg|
rpm_package pkg do
source pkg
action :install
end
end
Dir.glob
应返回所有包含完整路径的包,您可以遍历列表/数组。