我需要net-ssh和net-scp作为自定义OpsWorks主厨配方的一部分。
来自rubygems.org的偶然失败未能提供宝石,所以我想在S3上自己主持。
chef_gem有'source'参数,但似乎要求在chef启动之前存在本地文件(因此我无法在使用remote_file的chef_gem之前立即下载文件)
$gemSsh = "#{Chef::Config[:file_cache_path]}/net-ssh.gem"
$gemScp = "#{Chef::Config[:file_cache_path]}/net-scp.gem"
remote_file $gemSsh do
source "https://s3-us-west-2.amazonaws.com/****/net-ssh-2.9.1.gem"
action :nothing
end.run_action(:create)
remote_file $gemScp do
source "https://s3-us-west-2.amazonaws.com/****/net-scp-1.2.1.gem"
action :nothing
end.run_action(:create)
chef_gem "net-ssh" do
action :nothing
source $gemSsh
end.run_action(:install)
chef_gem "net-scp" do
action :nothing
source $gemScp
end.run_action(:install)
(注意:run_action(:install)基于此处的评论https://tickets.opscode.com/browse/CHEF-4843)
此操作失败,并显示以下错误:
NoMethodError
-------------
undefined method `name' for "/var/lib/aws/opsworks/cache.stage2/net-scp.gem":String
Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage2/cookbooks/opsworks_commons/libraries/monkey_patch_rubygems_provider.rb:55:in `install'
/var/lib/aws/opsworks/cache.stage2/cookbooks/****/recipes/default.rb:24:in `from_file'
答案 0 :(得分:0)
您可以使用" - local"由gem install提供的标志(您可以找到gem install --help
的其他选项。)
基本命令会像gem install --local path_to_gem/filename.gem
一样。所以你的食谱就是:
....
chef_gem "net-ssh" do
action :nothing
options("--local #{$gemSsh}")
end.run_action(:install)
chef_gem "net-scp" do
action :nothing
options("--local #{$gemScp}")
end.run_action(:install)