2014-12-02 90 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)