2014-12-02 92 views
0

我需要net-ssh和net-scp作爲自定義OpsWorks廚師食譜的一部分。從S3中安裝寶石OpsWorks廚師食譜

從rubygems.org獲取偶爾失敗提供的寶石,所以我想在S3上自己託管它們。

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) 

(注(chef_gem remote_file使用之前,讓我無法下載文件馬上)似乎需要在本地文件中存在之前,廚師正在啓動:在run_action(:安裝)基於評論這裏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

您可以使用「--loca l「標誌由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)