gpt4 book ai didi

provisioning - Chef : Why are resources in an "include_recipe" step being skipped?

转载 作者:行者123 更新时间:2023-12-03 10:23:39 25 4
gpt4 key购买 nike

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

include_recipe "build-essential"
include_recipe "mytardis::deps"
include_recipe "mytardis::nginx"
include_recipe "mytardis::postgresql"
mytardis-chef/cookbooks/build-essential/recipes/default.rb看起来像这样:
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 的旧版本)

在运行时,由于我不明白的原因,这个构建基本配方被加载但没有执行:
[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 配方。而且由于没有运行 build-essential (安装 C 编译器),后者失败了。

我的 Vagrantfile 的相关部分如下所示:
  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

我以前使用的是稍早版本的 Chef(可能是 10.10.0?)在那个版本中,build-essential 也没有运行,但 mytardis::deps 运行了。现在使用 Chef 10.12.0。物理机是 OSX,VM 是 Ubuntu Lucid。

所以,有几个问题:
  • 为什么 build-essential 没有被“处理”?
  • 这样做的正确方法是什么? (这些 Recipe 不是我写的,我知道他们为他们的作者做过或曾经为他们工作过。)
  • 站点 Recipe 和 Recipe 的“阴影”功能是否仍然有效?据说已弃用:http://tickets.opscode.com/browse/CHEF-2308 (我尝试在 site-cookbooks/mytardis/recipes/build-essential 下创建一个符号链接(symbolic link),但没有任何乐趣)。
  • 最佳答案

    事实证明,这是 Chef 工作方式中一个非常正常(但记录不足)的部分:它编译所有内容,然后开始运行。除了一些配方(如 Postgres)在编译时跳入队列以实际安装,使用如下代码:

      action :nothing
    end.run_action(:run)

    解决方案是任何需要在 Postgres 之前运行的东西也需要这样做。幸运的是, Build-essentials 的更新版本允许这个。您在角色上设置属性,如下所示:
    name "myapp"
    run_list(
    "recipe[build-essential]",
    "recipe[myapp]"
    )
    default_attributes(
    "build_essential" => {
    "compiletime" => true
    }
    )

    关于provisioning - Chef : Why are resources in an "include_recipe" step being skipped?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11380485/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com