2015-01-27 6 views
0

시작할 때 사용자 스크립트를 실행하고 싶은 인스턴스가 있습니다. 그래서userdata 인스턴스 시작시 실행할 루비 스크립트가 잘못된 루비 버전을 사용합니다

[email protected]:~$ which ruby 
/usr/bin/ruby 
[email protected]:~$ ruby -v 
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux-gnu] 
[email protected]:~$ gem list 

*** LOCAL GEMS *** 

aws-sdk (1.61.0) 
aws-sdk-v1 (1.61.0) 
bigdecimal (1.2.4) 
celluloid (0.15.2) 
celluloid-io (0.15.0) 
eye (0.6.3) 
io-console (0.4.2) 
json (1.8.1) 
mini_portile (0.6.2) 
minitest (4.7.5) 
nio4r (1.0.1) 
nokogiri (1.6.6.2) 
psych (2.0.5) 
rake (10.1.0) 
rdoc (4.1.0) 
sigar (0.7.3) 
state_machine (1.2.0) 
test-unit (2.1.5.0) 
thor (0.19.1) 
timers (1.1.0) 

:

Successfully installed mini_portile-0.6.2 
Building native extensions. This could take a while... 
Successfully installed nokogiri-1.6.6.2 
Successfully installed aws-sdk-v1-1.61.0 
Successfully installed aws-sdk-1.61.0 
Parsing documentation for aws-sdk-1.61.0 
Installing ri documentation for aws-sdk-1.61.0 
Parsing documentation for aws-sdk-v1-1.61.0 
Installing ri documentation for aws-sdk-v1-1.61.0 
Parsing documentation for mini_portile-0.6.2 
Installing ri documentation for mini_portile-0.6.2 
Parsing documentation for nokogiri-1.6.6.2 
Installing ri documentation for nokogiri-1.6.6.2 
Done installing documentation for aws-sdk, aws-sdk-v1, mini_portile, nokogiri after 55 seconds 
4 gems installed 
/usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- aws-sdk (LoadError) 
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from /var/lib/cloud/instance/scripts/zz_bootstrap.rb:8:in `<main>' 
2015-01-27 13:49:46,859 - util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/zz_bootstrap.rb [1] 
2015-01-27 13:49:46,875 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts) 
2015-01-27 13:49:46,875 - util.py[WARNING]: Running scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python2.7/dist-packages/cloudinit/config/cc_scripts_user.pyc'>) failed 
Cloud-init v. 0.7.5 finished at Tue, 27 Jan 2015 13:49:47 +0000. Datasource DataSourceEc2. Up 389.95 seconds 

그래서 유저 데이터의 범위를 벗어난다 확인하기로 결정 :이 얻을 로그에 그러나

Content-Type: multipart/mixed; boundary="===============zCWTbYbXsHmnlc1kxsQr93CA==" 
MIME-Version: 1.0 

--===============zCWTbYbXsHmnlc1kxsQr93CA== 
Content-Type: text/cloud-config; charset="us-ascii" 
MIME-Version: 1.0 
Content-Transfer-Encoding: 7bit 
Content-Disposition: attachment; filename="cloud-config" 

output: { all: '|tee -a /var/log/cloud-init-output.log' } 

--===============zCWTbYbXsHmnlc1kxsQr93CA== 
Content-Type: text/x-shellscript; charset="us-ascii" 
MIME-Version: 1.0 
Content-Transfer-Encoding: 7bit 
Content-Disposition: attachment; filename="zz_bootstrap.rb" 

#!/usr/bin/ruby 

require 'rubygems' 
require 'json' 

system "sudo gem install aws-sdk" 

require 'aws-sdk' 

r53=nil 
Retrier.new(3,1).run do 
    r53 = AWS::Route53.new( :access_key_id => creds["AccessKeyId"], 
           :secret_access_key => creds["SecretAccessKey"], 
           :region => region) 
end 

Some_ruby_stuff_that_needs_r53 

: 그래서 유저 데이터에서이 코드를 삽입 스크립트 내에서 "sudo gem install"이라고 부르더라도 잘못된 루비 버전의 보석을 설치합니다. 이것은 RVM이 없다. 어떤 루비 버전 (1.93 이상)이 실행되는지 신경 쓰지 않고, aws-sdk 젬을 사용해야합니다. 아이디어?

감사합니다. 예비 단계에서 설치

답변

0

이 해결 :

Content-Type: multipart/mixed; boundary="===============zCWTbYbXsHmnlc1kxsQr93CA==" 
MIME-Version: 1.0 

--===============zCWTbYbXsHmnlc1kxsQr93CA== 
Content-Type: text/cloud-config; charset="us-ascii" 
MIME-Version: 1.0 
Content-Transfer-Encoding: 7bit 
Content-Disposition: attachment; filename="cloud-config" 

runcmd를 : - "sudo는 보석 AWS-SDK를 설치"

output: { all: '|tee -a /var/log/cloud-init-output.log' } 

--===============zCWTbYbXsHmnlc1kxsQr93CA== 
Content-Type: text/x-shellscript; charset="us-ascii" 
MIME-Version: 1.0 
Content-Transfer-Encoding: 7bit 
Content-Disposition: attachment; filename="zz_bootstrap.rb"