厨师测试厨房 运行 仅默认食谱

chef test-kitchen run only default recipe

我在windows上安装了厨师工作站,我有2个食谱,默认和install_nginx,当我运行厨房收敛时,厨房只执行默认食谱。为了安全起见,我做了 kitchen verify 并且它给了我一个错误,因为安装了测试脚本 verificase nginx。你能告诉我为什么吗? 这是我 kitchen.yml

---
driver:
  name: vagrant

  network:
    - ["forwarded_port", {guest: 80, host: 8080}]

provisioner:
  name: chef_zero

verifier:
  name: inspec

platforms:
  - name: hashicorp/precise32

suites:
  - name: default
    run_list:
        -recipe[chef-example::default]
        -recipe[chef-example::install_nginx]
    verifier:
      inspec_tests:
        - test/integration/default
    attributes:

这是我的PolicyFile.rb

# Policyfile.rb - Describe how you want Chef Infra Client to build your system.
#
# For more information on the Policyfile feature, visit
# https://docs.chef.io/policyfile.html

# A name that describes what the system you're building with Chef does.
name 'chef-example'

# Where to find external cookbooks:
default_source :supermarket

# run_list: chef-client will run these recipes in the order specified.
run_list 'chef-example::default'

# Specify a custom source for a single cookbook:
cookbook 'chef-example', path: '.'

如果 Test Kitchen 使用策略文件,那么它也会从中获取 run_list。在这种情况下,kitchen.yml 中的 run_list 将被忽略。如果您需要具有不同 run_lists 的不同套件和策略文件,则需要使用多个策略文件。在这种情况下,我建议在其中设置 1 个具有不同策略的文件夹 policyfiles,并在 kitchen.yml

中进行以下配置
suites:
  - name: default
    provisioner:
      policyfile_path: policyfiles/default.rb
    verifier:
      inspec_tests:
        - test/integration/default   # can be omitted, as this is default place to look for tests
    attributes:
  - name: test1
    provisioner:
      policyfile_path: policyfiles/test1.rb
    verifier:
      inspec_tests:
        - test/integration/test1     # can be omitted, as this is default place to look for tests
    attributes: