私は料理の本からコミュニティconsulの料理本に依存しています。
私はconsulをサーバモードとクライアントモードに持っているので、名前空間を分けたいと思います。この場合
、私は私のレシピでは以下の構成を使用することができます。これは同じになぜ起こるかシェフがレシピ内の別の名前空間から属性を再割り当てすると、4レベルの配列で未定義のメソッドエラーが発生する
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/eax-consul-cluster/recipes/default.rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
:予想通り
node.default['consul']['config']['server'] = node['consul-server']['config']['server'] if node['consul-server']['config']['server']
node.default['consul']['config']['ui'] = node['consul-server']['config']['ui'] if node['consul-server']['config']['ui']
node.default['consul']['config']['ports']['http'] = node['consul-server']['config']['ports']['http'] if node['consul-server']['config']['ports']['http']
node.default['consul']['config']['ports']['https'] = node['consul-server']['config']['ports']['https'] if node['consul-server']['config']['ports']['https']
最初の二行のフォークが、次のエラーを生成する2つの最後の行をそれらの間の唯一の違いは、配列が1レベル深いことですか?
だから私はそれが 'if'セクションで起こると信じていますが、' if'はnilの場合は 'else'に移動しないでください。 – vvchik
もしconditionの値が 'nil'ならば' then'セクションの変数にこの値を代入する必要はありません – vvchik
'node ['consul-server'] ['config'] ['ports']' 'nil'ですが、どうなりますか? 'node ['consul-server'] ['config'] ['ports'] ['http']'は 'nil ['http']'であり、間違いなく間違いが発生します。 – Aetherus