0

I am trying to test a simple cookbook recipe using docker driver. But, I get an error.

Can someone please help? I really gave my all effort trying several things but none of them worked. I had installed docker kitchen driver also using command: chef gem install kitchen-docker. Below are my configurational files, chef versions, kitchen.yml file etc.

Chef version

Chef Workstation version: 22.6.973
Chef InSpec version: 4.56.20
Chef CLI version: 5.6.1
Chef Habitat version: 1.6.420
Test Kitchen version: 3.2.2
Cookstyle version: 7.32.1
Chef Infra Client version: 17.10.0

chef gem list kitchen-docker gives output as: kitchen-docker (2.13.0)

Below is my kitchen.yml file

---
driver:
  name: docker
  provision_command: curl -L https://www.chef.io/chef/install.sh | bash

provisioner:
  name: chef_zero

  ## product_name and product_version specifies a specific Chef product and version to install.
  ## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
  #  product_name: chef
  #  product_version: 17

verifier:
  name: inspec

platforms:
  - name: ubuntu
  - name: centos-7
    driver_config:
      image: 'centos:7'
      platform: centos

transport:
  name: docker

suites:
  - name: default
    run_list:
       - recipe[docker-cookbook::default]
    verifier:
      inspec_tests:
        - test/integration/default
    attributes:

My recipe: default.rb

#
# Cookbook:: docker-cookbook
# Recipe:: default
#
# Copyright:: 2022, The Authors, All Rights Reserved.

file '/tmp/test.txt' do
  content 'This is managed by Rapidops'
  action :create
end

But, when I do kitchen list, I am getting below error:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::UserError
>>>>>> Message: Kitchen YAML file /root/chef-repo/cookbooks/docker-cookbook/recipes/kitchen.yml does not exist.
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration
seshadri_c
  • 6,906
  • 2
  • 10
  • 24
Robin Raj
  • 1
  • 1
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community Jul 19 '22 at 14:24
  • The message states it very clearly: "Message: Kitchen YAML file /root/chef-repo/cookbooks/docker-cookbook/recipes/kitchen.yml does not exist.". Where is your kitchen.yml? – Draco Ater Jul 22 '22 at 10:38

1 Answers1

0

As per error message, you are trying to run kitchen commands from recipe directory - /root/chef-repo/cookbooks/docker-cookbook/recipes/kitchen.yml does not exist You should run kitchen commands from root level of cookbook. In you case, it is - /root/chef-repo/cookbooks/docker-cookbook

Parvez Kazi
  • 660
  • 5
  • 13