繁体   English   中英

在OpsWorks Chef配方中从S3安装gem

[英]Install gem from S3 in OpsWorks Chef recipe

我需要net-ssh和net-scp作为自定义OpsWorks主厨食谱的一部分。

由于rubygems.org偶尔会出现故障,无法提供gem,因此我想将它们托管在S3上。

Chef_gem具有'source'参数,但是它似乎要求本地文件在厨师启动之前就已经存在(因此,我不能在使用Chef_gem之前使用remote_file下载该文件)

$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'

您可以使用gem install提供的“ --local”标志(可以通过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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM