2012-07-08 7 views
26

シェフが異常な順序でリソースを処理しているようで、ビルドが失敗することがあります。私のメインのレシピ(mytardis-chef/site-cookbooks/recipes/default.rb)は次のように起動します:シェフ:「include_recipe」ステップのリソースがスキップされるのはなぜですか?

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の古いバージョンです)

実行時には、理由のために私は:

include_recipe "build-essential" 
include_recipe "mytardis::deps" 
include_recipe "mytardis::nginx" 
include_recipe "mytardis::postgresql" 

mytardis-chef/cookbooks/build-essential/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 

つまり、ビルドに不可欠なレシピは「見つかった」と「読み込まれました」ですが、最初に「処理された」ポストグルレシピです。そして、Cコンパイラをインストールするbuild-essentialは実行されなかったので、後者は失敗します。私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 

私は以前に(おそらく10.10.0?)シェフの少し以前のバージョンを使用していたそのバージョンでは、ビルド不可欠にも実行されていませんでした、しかしmytardis :: depsはあった。今シェフ10.12.0を使用しています。物理マシンはOSX、VMはUbuntu Lucidです。

ので、いくつかの質問:

  1. はなぜビルド必須では "処理" されていませんか?
  2. これは正しい方法はありますか? (私はこれらのレシピを書いていませんでしたが、彼らは作者のために働いたことを理解しています)
  3. サイトクックブックとクッキングブックのシャドーイング機能はまだ機能しますか?それはおそらく非難された:http://tickets.opscode.com/browse/CHEF-2308(私はサイトcookbook/mytardis /レシピ/ビルド - 不可欠だが、喜びから下のシンボリックリンクを作ろうとした)。それがすべてをコンパイルし、実行しているその後、開始:
+0

ビルド必須/レシピ/ default.rbにChef :: Log.info( "私は#{cookbook_name} ::#{recipe_name}"にあります)を置くことができます。レシピ。 "/var/chef/cache/failed-run-data.json"のような例外ハンドラで作成されたファイルには、ロードしたすべてのリソースのリソースコレクション全体が含まれているため、レシピが追加されました。 – jtimberman

+0

クックブックシャドーイング機能は、クッキングブックに存在するコンポーネントを、両方の場所に別々のクックブックを置くだけでなく、サイトクックブックに入れて上書きすることができる機能です。 – jtimberman

+0

これを解決できましたか? –

答えて

40

これはシェフがどのように動作するかのかなり正常な(しかし、下の文書化)一部ですが判明します。 (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 
    } 
) 
+1

これを回答としてマークすることを検討してください。 –

+1

今日私は 'database :: postgresql'に依存する別の料理ブックを使いました。これは' postgresql :: ruby​​'に依存しています。現在の 'postgresql :: ruby​​'のレシピは、シェフ実行の** Compilation **段階で' pg' gem、 'libpq'、' postgresql'をインストールします。これは、この答えが指摘しているように、 'run_action(:install)'を使ってこれを行います。 – TrinitronX

+0

特定のケースでこれを回避する別の方法があります。たとえば、 'postgresql :: ruby​​'を含むcookbookで' kitchen test'を実行すると、古くなったパッケージキャッシュからaptエラーが発生する可能性があります。これを修正するために、 'now'クッキングブックのDSLを使用してシェフの開始時に' apt-get update 'を強制的に実行することができます: 'include_recipe_now' apt'' – TrinitronX

6

、自分の属性に属性を追加ファイル:あなたは、次のような役割で属性を設定し、上記コリンへ

node.default['build_essential']['compiletime'] = true 

感謝を。

+0

これはbuild_essentialレシピに固有のものですか?どこでも働きますか?それは文書化されていますか? –

+0

スティーブ、その構文はどのレシピでも使用できます。ノードはシェフノードの「自己参照」です。デフォルトは、再度上書きされない限り、料理名/レシピの使用に適用されるセルフタイトルの設定です。その他の2つのオプションはbuild_essential固有のものです。 – toobulkeh

関連する問題