I cannot figure out to make my cookbook run correctly with kitchen ci. This is what I wrote and execute:
kitchen.yml
driver:
name: docker
binary: docker
use_sudo: false
provisioner:
name: chef_zero
always_update_cookbooks: true
chef_repo_path: ../..
nodes: ../../nodes
platforms:
- name: ubuntu-16.04
driver_plugin: docker
suites:
- name: default
data_bags_path: "../../data_bags"
encrypted_data_bag_secret_key_path: "../../data_bags/secrets/bitbucket.json"
run_list:
- recipe[redmine_test]
verifier:
name: inspec
Berksfile in my cookbook folder:
source 'https://supermarket.chef.io'
metadata
cookbook 'nginx', '~> 2.7.6'
cookbook 'logrotate', '~> 1.9.2'
Commands that I run:
$ berks vendor
$ kitchen create && kitchen converge -l debug
This is the error I get:
================================================================================
Recipe Compile Error in /tmp/kitchen/cache/cookbooks/redmine_test/recipes/default.rb
================================================================================
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/tmp/kitchen/cache/cookbooks/redmine_test/recipes/default.rb:73:in `block in from_file'
/tmp/kitchen/cache/cookbooks/redmine_test/recipes/default.rb:70:in `from_file'
Relevant File Content:
----------------------
/tmp/kitchen/cache/cookbooks/redmine_test/recipes/default.rb:
66: action :add
67: end
68: end
69:
70: directory "redmine_repos" do
71: path lazy { "#{node['etc']['passwd'][node['redmine']['user']]['dir']}/repos" }
72: owner node['redmine']['user']
73>> group node['nginx']['group']
74: mode 02775
75: end
76:
How come do I get this error? whereas the group node['nginx']['group'] variable is well defined in the nginx cookbook that has been vendored.
Thanks
nginxcookbook has to be part (depends nginx) of your metadata.rb. Or it has to be on your run_list.Also,
2.7.6is pretty old, there is7.xalready.