ruby将String隐式转换为Chef recipe中的整数

时间:2017-07-18 16:40:16

标签: ruby chef chef-recipe test-kitchen

我在包装文件中使用最新的apache2食谱(v5.0.0)。我的包装配方只包括apache2配方,所以当我尝试设置测试套件时,我不确定在我的厨房测试中是什么原因造成了这个错误???

包装食谱

   include_recipe 'apache2'

厨房设置错误

   ...
   Synchronizing Cookbooks:
     - my-webapp (2.0.0)
     - apache2 (5.0.0)
   Installing Cookbook Gems:
   Compiling Cookbooks...

   ================================================================================
   Recipe Compile Error in /tmp/kitchen/cache/cookbooks/apache2/attributes/default.rb
   ================================================================================

   TypeError
   ---------
   no implicit conversion of String into Integer

   Cookbook Trace:
   ---------------
     /tmp/kitchen/cache/cookbooks/apache2/attributes/default.rb:90:in `from_file'

   Relevant File Content:
   ----------------------
   /tmp/kitchen/cache/cookbooks/apache2/attributes/default.rb:

    83:    default['apache']['pid_file']    = '/var/run/httpd2.pid'
    84:    default['apache']['lib_dir']     = node['kernel']['machine'] =~ /^i[36]86$/ ? '/usr/lib/apache2' : '/usr/lib64/apache2'
    85:    default['apache']['libexec_dir'] = node['apache']['lib_dir']
    86:  when 'debian'
    87:    default['apache']['package']     = 'apache2'
    88:    default['apache']['perl_pkg']    = 'perl'
    89:    default['apache']['devel_package'] =
    90>>     if node['apache']['mpm'] == 'prefork'
    91:        'apache2-prefork-dev'
    92:      else
    93:        'apache2-dev'
    94:      end
    95:    default['apache']['apachectl']   = '/usr/sbin/apache2ctl'
    96:    default['apache']['dir']         = '/etc/apache2'
    97:    default['apache']['log_dir']     = '/var/log/apache2'
    98:    default['apache']['error_log']   = 'error.log'
    99:    default['apache']['access_log']  = 'access.log'

   System Info:
   ------------
   chef_version=13.0.118
   platform=ubuntu
   platform_version=16.04
   ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
   program_name=chef-client worker: ppid=3084;start=16:38:30;
   executable=/opt/chef/bin/chef-client

1 个答案:

答案 0 :(得分:2)

正如工程师所提到的,检查覆盖和正常级别属性(或来自roles / envs的默认值)。偷偷摸摸的通常是正常的,通过knife node edit检查。可能的情况是node['apache']被设置为数组。