2017-10-25 17 views
0

요리사 및 방미제를 제공 업체로 사용하고 있습니다.보석을 설치할 때 요리사가 충돌합니다

나는 응용 프로그램 충돌, 다음과 같이 보석을 설치하려고 할 때 :

metadata.rb

gem 'faraday' 
gem 'json' 

default.rb이 오류가

require 'faraday' 
require 'json' 

conn = Faraday.new(:url => 'http://127.0.0.1:8200') 

을 제기

:

==> default: Running handlers: 
==> default: [2017-10-25T09:42:43+00:00] ERROR: Running exception handlers 
==> default: Running handlers complete 
==> default: [2017-10-25T09:42:43+00:00] ERROR: Exception handlers complete 
==> default: Chef Client failed. 0 resources updated in 19 seconds 
==> default: [2017-10-25T09:42:43+00:00] INFO: Sending resource update report (run-id: 7f4593f5-1c86-409c-95fe-988f09501740) 
==> default: [2017-10-25T09:42:43+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out 
==> default: [2017-10-25T09:42:43+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report 
==> default: [2017-10-25T09:42:43+00:00] ERROR: Expected process to exit with [0], but received '5' 
==> default: ---- Begin output of bundle install ---- 
==> default: STDOUT: Don't run Bundler as root. Bundler can ask for sudo if it is needed, and 
==> default: installing your bundle as root will break this application for all non-root 
==> default: users on this machine. 
==> default: Fetching gem metadata from https://rubygems.org/ 
==> default: Fetching version metadata from https://rubygems.org/ 
==> default: Resolving dependencies... 
==> default: Installing multipart-post 2.0.0 
==> default: Installing json 2.1.0 with native extensions 
==> default: 
==> default: Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 
==> default: 
==> default:  current directory: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/json-2.1.0/ext/json/ext/generator 
==> default: /opt/chef/embedded/bin/ruby -r ./siteconf20171025-3434-1qh8whd.rb extconf.rb 
==> default: creating Makefile 
==> default: 
==> default: current directory: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/json-2.1.0/ext/json/ext/generator 
==> default: make "DESTDIR=" clean 
==> default: 
==> default: current directory: /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/json-2.1.0/ext/json/ext/generator 
==> default: make "DESTDIR=" 
==> default: compiling generator.c 
==> default: make: gcc: Command not found 
==> default: make: *** [generator.o] Error 127 
==> default: 
==> default: make failed, exit code 2 
==> default: 
==> default: Gem files will remain installed in /opt/chef/embedded/lib/ruby/gems/2.3.0/gems/json-2.1.0 for inspection. 
==> default: Results logged to /opt/chef/embedded/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0/json-2.1.0/gem_make.out 
==> default: Using bundler 1.12.5 
==> default: Installing faraday 0.13.1 
==> default: An error occurred while installing json (2.1.0), and Bundler cannot continue. 
==> default: Make sure that `gem install json -v '2.1.0'` succeeds before bundling. 
==> default: STDERR: 
==> default: ---- End output of bundle install ---- 
==> default: Ran bundle install returned 5 
==> default: [2017-10-25T09:42:43+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) 
Chef never successfully completed! Any errors should be visible in the 
output above. Please fix your recipes so that they properly complete. 

hat gcc가 빠졌지 만 보석을 설치하려고 시도한 다음 조리법을 실행하기 때문에 설치할 수 없으므로 아무것도 할 수 없기 때문에 충돌이 발생합니다.

- 편집 - 나는이 라인을 추가했고 노력

:

metadata.rb :

depends 'hashicorp-vault', '~> 2.5.0' 
depends 'build-essential', '~> 8.0.3' 

default.rb을 (여기에서 보석 의존성을 제거) :

include_recipe 'hashicorp-vault::default' 
chef_gem 'faraday' 
chef_gem 'json' 
require 'faraday' 
require 'json' 
+0

'make : gcc : Command not found'는 gcc가 설치되지 않았 음을 의미합니다. 설치해야합니까, 운영 체제는 무엇입니까? –

+0

gcc가 없으므로 문제는 어떻게 그 의존성을 해결할 수 있는지입니다. Vagrant가 CentOS 7을 프로비저닝하고 있습니다. – Lechucico

+0

'sudo yum groupinstall 'Development Tools'을 실행 해보십시오. 그러면 gcc를 포함하여 상자에 필요한 빌드 도구가 설치됩니다. 'gcc'가 Ruby gem을 설치하는 방법에 따라 어떻게 달라지는지는 모르겠지만 실제로는 그렇지 않습니다. –

답변

2

에게 gcc를 설치하는 요리사-Y 방법을 가지고 계획이라면 당신에게 더 많은 유연성을 제공하는 것은 build-essential 요리 책을 사용하는 것입니다.

0

요리사 프로비저닝 전에 셸 프로비저를 추가 하시겠습니까? 예를 들어 당신의 Vagrantfile에서

: 당신이 수동으로 핀치에 요리사와 함께 할 수있는 수행하는 방법을 알고, 그래서 만약

Vagrant.configure("2") do |config| 
    config.vm.provision :shell, inline: 'yum install -y gcc' 
    config.vm.provision :chef, inline: '...' 
end 
+0

그게 작동하지만 우분투에 대한 내 CentOS를 변경하면 어떨까요? 그건 효과가 없을거야. – Lechucico

+0

그러면 실행중인 OS를 감지하고 적절한 명령을 실행하는 논리를 작성합니다. 그런 종류의 일은 아주 흔합니다. – d1ll1nger

0

조리법, 임의의 명령을 실행 완벽하게 할 수있다. 즉, 임의의 명령을 지켜서 조리법이 실행될 때마다 실행되지 않도록해야한다는 것입니다. 필요할 때만 실행됩니다.

execute 'sudo yum groupinstall \'Development Tools\'' unless <your logic for 
detecting gcc goes here> 

요리사는 또한 심지어에서 작동하는지 OS를 포함하여, 시작하기 전에 실행에 대한 메타 데이터를 수집 Ohai을 가지고, 그래서 당신은 그것을 활용하여 조리법 멀티 플랫폼을 만들 수 있습니다.

include_recipe 'mycookbook::debian' if node['platform_family'] == 'debian' 
include_recipe 'mycookbook::rhel' if node['platform_family'] == 'rhel' 

https://docs.chef.io/dsl_recipe.html

또는, 당신은 많은 플랫폼 유형

possible_platforms = ['debian', 'rhel'] 
if possible_platforms.contains? node['platform_family'] 
    include_recipe "mycookbook::node['platform_family']" 
else 
    puts 'This platform isn't valid' 
end