夥計們,我對廚師獨奏屬性感到迷茫。我有一堆接受者,其中一些曾經被編碼爲角色,而當他們大多數人都能正常工作時。因此,例如,我曾經有一個角色:廚師獨奏:未設置屬性的問題
name "apache"
description "Configure php5.3 and apache2 with mod_php."
run_list ("recipe[php]", "recipe[apache2]")
我現在有:
# "Configure php5.3 and apache2 with mod_php."
include_recipe "php"
include_recipe "apache2"
這似乎很容易,但我現在遇到了問題屬性。的「PHP」菜譜配方有屬性在其default.rb文件和代碼失敗,錯誤:
NoMethodError
-------------
undefined method `[]' for nil:NilClass
在標準的PHP食譜的PHP /食譜/ default.rb行:
include_recipe "php::#{node['php']['install_method']}"
我相信這是因爲屬性文件還沒有運行,因爲如果它運行的值install_method將被設置爲'包'。我不認爲這個問題是專門針對「php」配方的,儘管我想它可能是。
我找不到任何東西來表明給定的屬性文件運行在哪個環境中,除了關於正在按字母順序讀取的文件的隱祕評論(儘管何時沒有聲明)。
例如,當使用食譜中的任何食譜時,是否運行attribute/default.rb? 無論使用烹飪書,是否所有屬性文件都被加載? 它是否只是其名稱與正在運行的配方相匹配的屬性文件?
你有什麼想法我可以調試嗎?
編輯:添加一些錯誤信息:文件被加載
[2013-10-26T22:44:10+00:00] DEBUG: Loading Recipe el-drupal-cookbook::apache2_mod_php via include_recipe
[2013-10-26T22:44:10+00:00] DEBUG: Found recipe apache2_mod_php in cookbook el-drupal-cookbook
[2013-10-26T22:44:10+00:00] DEBUG: Loading Recipe php via include_recipe
[2013-10-26T22:44:10+00:00] DEBUG: Found recipe default in cookbook php
[2013-10-26T22:44:10+00:00] DEBUG: filtered backtrace of compile error: /tmp/vagrant-chef-1/chef-solo-1/ cookbooks/php/recipes/default.rb:22:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/apache2_mod_php.rb:3:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/drupal_lamp_dev.rb:4:in `from_file'
[2013-10-26T22:44:10+00:00] DEBUG: filtered backtrace of compile error: /tmp/vagrant-chef-1/chef-solo-1/ cookbooks/php/recipes/default.rb:22:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/apache2_mod_php.rb:3:in `from_file',/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal- cookbook/recipes/drupal_lamp_dev.rb:4:in `from_file'
[2013-10-26T22:44:10+00:00] DEBUG: backtrace entry for compile error: '/tmp/vagrant-chef-1/chef-solo-1/ cookbooks/php/recipes/default.rb:22:in `from_file''
[2013-10-26T22:44:10+00:00] DEBUG: Line number of compile error: '22'
================================================================================
Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal-cookbook/recipes/drupal_lamp_dev .rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php/recipes/default.rb:22:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal-cookbook/recipes/apache2_mod_php.rb:3:in `from_file'
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/el-drupal-cookbook/recipes/drupal_lamp_dev.rb:4:in `from_file'
Relevant File Content:
----------------------
/tmp/vagrant-chef-1/chef-solo-1/cookbooks/php/recipes/default.rb:
15: # Unless required by applicable law or agreed to in writing, software
16: # distributed under the License is distributed on an "AS IS" BASIS,
17: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: # See the License for the specific language governing permissions and
19: # limitations under the License.
20: #
21:
22>> include_recipe "php::#{node['php']['install_method']}"
23:
24: # update the main channels
25: php_pear_channel 'pear.php.net' do
26: action :update
27: end
28:
我認爲簡短的答案是否定的,我不能......我儘可能提出了流浪客戶,然後ssh進入並跑了「sudo chef-solo -c solo.rb -j dna.json「再次運行配置,並以同樣的方式失敗。然後,我編輯了cookbook/php/recipes/default.php以添加您在開始時建議的行。再次冉廚師。運行失敗而不打印任何附加信息(出於與原來相同的原因)。註釋掉文件的其餘部分並再次嘗試,但仍然失敗(稍後,因爲我已經註釋了pear_php定義)。仍然沒有調試值。不知道該怎麼嘗試。 – rivimey
只是爲了確認:在註釋掉之後,我確實看到了一條關於正在加載的php配方的消息,但僅此而已。 – rivimey