Chef_nginx: no implicit conversion of String into Integer

Hello

Using the chef_nginx from Supermarket, or rather, cloned master from Github, I get the following error:

~/ sudo /usr/bin/chef-client -j /opt/nginx-rp-kitchen/nodes/vorlage.standard.json -c /opt/nginx-rp-kitchen/client.rb
Starting Chef Client, version 12.19.36
resolving cookbooks for run list: ["ew-nginx-rp"]
Synchronizing Cookbooks:
  - ew-nginx-rp (0.0.1)
  - chef_nginx (6.1.1)
  - empty (0.0.999)
  - ohai (5.1.0)
  - yum-epel (2.1.2)
  - compat_resource (12.19.0)
  - zypper (0.4.0)
Installing Cookbook Gems:
Compiling Cookbooks...

================================================================================
Recipe Compile Error in /opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/default.rb
================================================================================

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

Cookbook Trace:
---------------
  /opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/default.rb:64:in `from_file'

Relevant File Content:
----------------------
/opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/default.rb:

 57:    default['nginx']['user']       = 'www-data'
 58:  end
 59:  
 60:  default['nginx']['upstart']['runlevels']     = '2345'
 61:  default['nginx']['upstart']['respawn_limit'] = nil
 62:  default['nginx']['upstart']['foreground']    = true
 63:  
 64>> default['nginx']['group'] = node['nginx']['group'] || node['nginx']['user']
 65:  
 66:  default['nginx']['gzip']              = 'on'
 67:  default['nginx']['gzip_static']       = 'off'
 68:  default['nginx']['gzip_http_version'] = '1.0'
 69:  default['nginx']['gzip_comp_level']   = '2'
 70:  default['nginx']['gzip_proxied']      = 'any'
 71:  default['nginx']['gzip_vary']         = 'off'
 72:  default['nginx']['gzip_buffers']      = nil
 73:  default['nginx']['gzip_types'] = %w(

Platform:
---------
x86_64-linux


Running handlers:
Running handlers complete
Chef Client failed. 0 resources updated in 06 seconds

=> no implicit conversion of String into Integer for node['nginx']['group'] || node['nginx']['user'].

What’s up with this?

I’m running this on a Ubuntu 16.04 system with Chef v12.19.36 from chef.io.

Shouldn’t it be so, that at least node['nginx']['user'] is set and set to the fallback value of www-data?

Regards,
Alexander

And it goes on…

================================================================================
Recipe Compile Error in /opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/devel.rb
================================================================================

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

Cookbook Trace:
---------------
  /opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/devel.rb:23:in `from_file'

Relevant File Content:
----------------------
/opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/devel.rb:

 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:  default['nginx']['devel']['version']  = '0.3.0'
 23>> default['nginx']['devel']['url']      = "https://github.com/simpl/ngx_devel_kit/archive/v#{node['nginx']['devel']['version']}.tar.gz"
 24:  default['nginx']['devel']['checksum'] = '88e05a99a8a7419066f5ae75966fb1efc409bad4522d14986da074554ae61619'
 25:  

Platform:
---------
x86_64-linux

Why is all of this happening?

Hello

For debug, I now modified the devel.rb and get the following error:

================================================================================
Recipe Compile Error in /opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/devel.rb
================================================================================

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

Cookbook Trace:
---------------
  /opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/devel.rb:25:in `from_file'

Relevant File Content:
----------------------
/opt/nginx-rp-kitchen/local-mode-cache/cache/cookbooks/chef_nginx/attributes/devel.rb:

 18:  # See the License for the specific language governing permissions and
 19:  # limitations under the License.
 20:  #
 21:  
 22:  default['nginx']['devel']['version']  = '0.3.0'
 23:  default['nginxdevelversion']  = '0.3.0'
 24:  default['nginxdevelurl']      = "https://github.com/simpl/ngx_devel_kit/archive/v#{node['nginxdevelversion']}.tar.gz"
 25>> default['nginx']['devel']['url']      = "https://github.com/simpl/ngx_devel_kit/archive/v#{node['nginx']['devel']['version']}.tar.gz"
 26:  default['nginx']['devel']['checksum'] = '88e05a99a8a7419066f5ae75966fb1efc409bad4522d14986da074554ae61619'
 27:  

System Info:
------------
chef_version=12.21.1
platform=ubuntu
platform_version=16.04
ruby=ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
program_name=chef-client worker: ppid=2264;start=09:51:55;
executable=/opt/chef/bin/chef-client


Running handlers:
Running handlers complete
Chef Client failed. 0 resources updated in 06 seconds

As can be seen in the error message, I added the following two lines:

default['nginxdevelversion']  = '0.3.0'
default['nginxdevelurl']      = "https://github.com/simpl/ngx_devel_kit/archive/v#{node['nginxdevelversion']}.tar.gz"

When Chef/ruby tries to evaluate #{node['nginx']['devel']['version']}, it throws an error.

Why is that?

Regards,
Alexander

I’m giving up… I don’t get at all, why there are so many issues.

On https://github.com/alexs77/misc/tree/master/Bugreports/chef_nginx I uploaded all the files that I have for this project. On my system, they are from /opt/nginx-rp-kitchen. There’s also a tar-ball at https://github.com/alexs77/misc/raw/master/Bugreports/chef_nginx/nginx-rp-kitchen.tar

I started chef-client with this command:

sudo /usr/bin/chef-client -j /opt/nginx-rp-kitchen/nodes/vorlage.standard.json -c /opt/nginx-rp-kitchen/client.rb

If somebody could please help, that would be so much appreciated!

@Alexander_Skwar, I admit, this is a rather confusing one.

I use chef_nginx quite a bit, albeit using only its basic functionality.

It would appear that, for whatever reason, Chef is not setting node['nginx']['devel']['version'] in time for node['nginx']['devel']['url'] to properly receive it. Which, of course, seems silly, since you have your example version just above that does the same thing and works great (albeit with only one level in the attribute).

Perhaps helpful, as I see you’ve had some trouble w/ this cookbook overall:

  • What version of Chef Client are you using?
  • Are you using Berkshelf?
  • Have you tested out your nginx-rp-kitchen cookbook using Test Kitchen locally?
  • Why the devel stuff? Are you attempting to compile the ngx_devel module into your build of NGINX?

Hello Jeff

Yes, that is quite confusing… To me, it seems, as if Ruby or Chef has
issues with these multi level hashes. Which doesn’t make sense either (that
there are issues, I mean).

I’m not using berkshelf at this moment.
I’m using Chef v12.19.x, but have also tried 12.20, 12.21 and 13.1, all
downloaded from chef.io.

I haven’t tried nginx-rp-kitchen but I will do so. I’m not using
test-kitchen either.

Why the development stuff? I don’t know, I don’t want it, but it’s an
attribute and all the attribute files are merged together. That’s why it’s
there, I guess.

Regards,
Alexander

I would definitely start using Berkshelf; you’re giving yourself a cookbook dependency headache otherwise. At the very least, you can use it to gather all the cookbooks you need, then upload them via another means if you’re not planning on using Chef Server.

Good to know the Chef versions you’ve tried. By the way, for local development, I cannot encourage using the Chef DK more highly. Downloading specific versions of the Chef Client is generally a bad idea.

Same goes for Test Kitchen; you’ll want to use that to do test runs of your cookbook’s convergence, either with Vagrant + a virtualization software (e.g., VirtualBox), or a cloud provider (EC2, Digital Ocean, etc.)

Before diving more into the specific issue you’re having, I suggest that you:

  1. Uninstall any manually (whether via omnitruck or package system) Chef installations you have
  2. Install Chef DK (and, if necessary, Vagrant & VirtualBox)
  3. Update your ew-nginx-rp wrapper cookbook to:
    • Use Berkshelf (Berksfile)
    • Use Test Kitchen (.kitchen.yml config)
  4. Use kitchen to create & converge a test instance of your ew-nginx-rp cookbook

The reasons for this are many, but some highlights:

  • Chef DK has its own, self-contained installation of Ruby, and is meant for local development of cookbooks
  • Using Test Kitchen automates away a ton of fiddly settings and steps, allowing you to focus on the cookbooks
  • Berkshelf avoids having to do anything more than set reasonable dependencies in your own cookbooks’ metadata, and means you need not manually manage publicly available upstream dependencies

Please try developing your wrapper cookbook this recommended way (it is the official recommendation, too), and if you are still having difficulty, then let’s dig in once we have comparable, consistent environments.

By the by, once you have Chef DK installed, you can generate a “Chef company-recommended cookbook” using this command: chef generate cookbook $name-of-cookbook. Be sure to run that from a place where your knife.rb is available, as it will need those settings to work properly.

It may prove helpful to do this, and then layer your ew-nginx-rp settings into it. This will give you a cookbook that:

  • Uses Berkshelf
  • Uses Test Kitchen
  • Has ChefSpec unit tests (run them with chef exec rspec from inside the cookbook directory)
  • Has Inspec integration tests, wired up to run at the conclusion of a Test Kitchen run