2012年12月16日日曜日

【chef】FATAL: NoMethodError: undefined method `length' fornil:NilClass

[2012-12-16T15:58:11+09:00] INFO: *** Chef 10.16.2 ***
[2012-12-16T15:58:20+09:00] INFO: Run List is []
[2012-12-16T15:58:20+09:00] INFO: Run List expands to []
[2012-12-16T15:58:20+09:00] INFO: Starting Chef Run for yoshi2
[2012-12-16T15:58:20+09:00] INFO: Running start handlers
[2012-12-16T15:58:20+09:00] INFO: Start handlers complete.
[2012-12-16T15:58:21+09:00] WARN: Missing gem 'right_aws'
[2012-12-16T15:58:21+09:00] INFO: Missing gem 'mysql'

================================================================================

Recipe Compile Error in C:/opscode/chef-repo/cookbooks/openldap/attributes/default.rb
================================================================================


NoMethodError
-------------
undefined method `length' for nil:NilClass

Cookbook Trace:
---------------
  C:/opscode/chef-repo/cookbooks/openldap/attributes/default.rb:19:in `from_file'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/from_file.rb:30:in `instance_eval'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/mixin/from_file.rb:30:in `from_file'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:192:in `block in load_attributes'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:230:in `call'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:230:in `block (2 levels) in foreach_cookbook_load_segment'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:229:in `each'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:229:in `block in foreach_cookbook_load_segment'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_cotext.rb:227:in `each'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:227:in `foreach_cookbook_load_segment'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:189:in `load_attributes'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/run_context.rb:65:in `load'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:198:in `setup_run_context'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:418:in `do_run'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/client.rb:176:in `run'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:140:in `run_chef_client'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:224:in `block in run_application'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:216:in `loop'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application/solo.rb:216:in `run_application'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/lib/chef/application.rb:72:in `run'
  c:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.16.2/bin/chef-solo:25:in `<top (required)>'
  c:/opscode/chef/bin/chef-solo:19:in `load'  c:/opscode/chef/bin/chef-solo:19:in `<main>'
Relevant File Content:
----------------------
C:/opscode/chef-repo/cookbooks/openldap/attributes/default.rb:

 12:  # Unless required by applicable law or agreed to in writing, software
 13:  # distributed under the License is distributed on an "AS IS" BASIS,
 14:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15:  # See the License for the specific language governing permissions and
 16:  # limitations under the License.
 17:  #
 18:
 19>> if domain.length > 0
 20:    default[:openldap][:basedn] = "dc=#{domain.split('.').join(",dc=")}"
 21:    default[:openldap][:server] = "ldap.#{domain}"
 22:  end
 23:
 24:  openldap[:rootpw] = nil
 25:
 26:  # File and directory locations for openldap.
 27:  case platform
 28:  when "redhat","centos"

[2012-12-16T15:58:21+09:00] ERROR: Running exception handlers
[2012-12-16T15:58:21+09:00] ERROR: Exception handlers complete
[2012-12-16T15:58:21+09:00] FATAL: Stacktrace dumped to C:/chef/cache/chef-stacktrace.out
[2012-12-16T15:58:21+09:00] FATAL: NoMethodError: undefined method `length' fornil:NilClass



とまぁこんな感じでchef-solo実行時にエラーになってしまいました。
環境はWindowsです。
いろいろ調べたんですが、どうやってもダメでした。
で結局たどり着いた解は

rm -rf chef-repo/cookbooks/openldap/

ってな感じでcookbooks自体を削除してしまうことでしたw
バグなのかなーと思ったけどとりあえずこれで回避できました

0 件のコメント:

コメントを投稿