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

问题描述 投票:0回答:1

我在Windows上安装了厨师工作站,我有2个配方,默认配方和install_nginx,当我运行kitchen converge时,kitchen只执行默认配方。为了安全起见,我会进行厨房验证,这会给我一个错误,因为已安装了测试脚本verificase nginx。你能告诉我为什么吗?这是miy 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: '.'
rubygems chef chef-recipe test-kitchen
1个回答
0
投票

如果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:
© www.soinside.com 2019 - 2024. All rights reserved.