簡體   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