【问题标题】:How to Test Cookbook in CHEF using DOCKER如何使用 DOCKER 在 CHEF 中测试 Cookbook
【发布时间】:2022-08-08 17:07:29
【问题描述】:

我正在尝试使用 docker 驱动程序测试一个简单的食谱食谱。但是,我得到一个错误。

有人可以帮忙吗?我真的竭尽全力尝试了几件事,但都没有奏效。我还使用命令安装了 docker kitchen 驱动程序:chef gem install kitchen-docker。下面是我的配置文件、厨师版本、kitchen.yml 文件等。

厨师版

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 输出为:kitchen-docker (2.13.0)

以下是我的kitchen.yml 文件

---
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:

我的食谱: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

但是,当我执行kitchen list 时,我遇到了以下错误:

>>>>>> ------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
  • 请修剪您的代码,以便更容易找到您的问题。请按照以下指南创建minimal reproducible example
  • 该消息非常清楚地说明:“消息:厨房 YAML 文件 /root/chef-repo/cookbooks/docker-cookbook/recipes/kitchen.yml 不存在。\”。你的厨房.yml 在哪里?

标签: docker chef-infra cookbook inspec


【解决方案1】:

根据错误消息,您正在尝试从配方目录运行 kitchen 命令 - /root/chef-repo/cookbooks/docker-cookbook/recipes/kitchen.yml does not exist 您应该从食谱的根级别运行厨房命令。 在你的情况下,它是 - /root/chef-repo/cookbooks/docker-cookbook

【讨论】:

    猜你喜欢
    • 2013-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 2015-01-19
    相关资源
    最近更新 更多