首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >厨师:为什么资源在"include_recipe“步骤中被跳过?

厨师:为什么资源在"include_recipe“步骤中被跳过?
EN

Stack Overflow用户
提问于 2012-07-08 03:39:17
回答 2查看 28.8K关注 0票数 28

厨师似乎在以奇怪的顺序处理资源,导致我的构建失败。我的主要菜谱(mytardis-chef/site-cookbooks/recipes/default.rb)是这样开始的:

代码语言:javascript
复制
include_recipe "build-essential"
include_recipe "mytardis::deps"
include_recipe "mytardis::nginx"
include_recipe "mytardis::postgresql"

mytardis-chef/cookbooks/build-essential/recipes/default.rb看起来是这样的:

代码语言:javascript
复制
case node['platform']
when "ubuntu","debian"
  %w{build-essential binutils-doc}.each do |pkg|
    package pkg do
      action :install
    end
  end
when "centos","redhat","fedora","scientific"
  %w{gcc gcc-c++ kernel-devel make}.each do |pkg|
    package pkg do
      action :install
    end
  end
end

..。(这是https://github.com/opscode-cookbooks/build-essential/blob/master/recipes/default.rb的旧版本)

在运行时,由于我不明白的原因,这个构建必需的配方会被加载,但不会执行:

代码语言:javascript
复制
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] Mounting shared folders...
[default] -- v-root: /vagrant
[default] -- v-csr-3: /tmp/vagrant-chef-1/chef-solo-3/roles
[default] -- v-csc-2: /tmp/vagrant-chef-1/chef-solo-2/cookbooks
[default] -- v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks
[default] -- v-csdb-4: /tmp/vagrant-chef-1/chef-solo-4/data_bags
[default] Running provisioner: Vagrant::Provisioners::ChefSolo...
[default] Generating chef JSON and uploading...
[default] Running chef-solo...
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: *** Chef 10.12.0 ***
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Building node object for lucid32
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Extracting run list from JSON attributes provided on command line
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Setting the run_list to ["recipe[mytardis]"] from JSON
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Applying attributes from json file
[Sun, 08 Jul 2012 05:14:32 +0200] DEBUG: Platform is ubuntu version 10.04
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Run List is [recipe[mytardis]]
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Run List expands to [mytardis]
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Starting Chef Run for lucid32
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Running start handlers
[Sun, 08 Jul 2012 05:14:32 +0200] INFO: Start handlers complete.
...
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe default in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe build-essential via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe default in cookbook build-essential
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis::deps via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe deps in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis::nginx via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe nginx in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe iptables via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe default in cookbook iptables
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe mytardis::postgresql via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe postgresql in cookbook mytardis
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe postgresql::server via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe server in cookbook postgresql
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Loading Recipe postgresql::client via include_recipe
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: Found recipe client in cookbook postgresql
[Sun, 08 Jul 2012 05:14:33 +0200] INFO: Processing package[postgresql-client] action install (postgresql::client line 37)
[Sun, 08 Jul 2012 05:14:33 +0200] DEBUG: package[postgresql-client] checking package status for postgresql-client
....
[Sun, 08 Jul 2012 05:14:45 +0200] ERROR: gem_package[pg] (postgresql::client line 42) has had an error
.
make
sh: make: not found

也就是说,构建必需的配方是“找到”和“加载”,但首先得到“处理”的是postgres配方。而且,由于构建必需(安装C编译器)没有运行,后者就失败了。

我的Vagrantfile文件的相关部分如下:

代码语言:javascript
复制
  config.vm.provision :chef_solo do |chef|
     chef.log_level = :debug
     chef.cookbooks_path = ["mytardis-chef/site-cookbooks", "mytardis-chef/cookbooks"]
     chef.roles_path = "mytardis-chef/roles"
     chef.data_bags_path = "mytardis-chef/data_bags"
     chef.add_recipe "mytardis"    
  end

我以前使用的是稍微早一点的厨师版本(大概10.10.0?)在那个版本中,构建基本功能也没有运行,但是mytardis::deps是。现在使用主厨10.12.0。物理机器是OSX,VM是Ubuntu。

所以,有几个问题:

  1. 为什么构建是必要的而不是“处理”的?
  2. 怎么做才是对的?(这些菜谱不是我写的,我知道它们确实是或曾经为作者工作过。)
  3. 网站--烹饪书和烹饪书的“阴影”功能还能用吗?它被认为是不可取的:http://tickets.opscode.com/browse/CHEF-2308 (我试着在http://tickets.opscode.com/browse/CHEF-2308下面做一个象征性链接,但没有joy)。
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-30 23:17:56

事实证明,这是厨师工作方式的一个相当正常的部分(但文档不足):它编译了所有的东西,然后开始运行。除了一些菜谱(如Postgres)之外,使用如下代码跳出队列,在编译时实际安装:

代码语言:javascript
复制
  action :nothing
end.run_action(:run)

解决方案是,在Postgres之前需要运行的任何东西也需要这样做。幸运的是,较新版本的建筑要领允许这样做。您将角色的属性设置为:

代码语言:javascript
复制
name "myapp"
run_list(
  "recipe[build-essential]",
  "recipe[myapp]"
)
default_attributes(
  "build_essential" => {
    "compiletime" => true
  }
)
票数 40
EN

Stack Overflow用户

发布于 2013-05-03 20:44:22

如果编写食谱,则将该属性添加到属性文件中:

代码语言:javascript
复制
node.default['build_essential']['compiletime'] = true

多亏了上面的科林。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11380485

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档