【问题标题】:Can we add a role in kitchen.yml?我们可以在 kitchen.yml 中添加一个角色吗?
【发布时间】:2017-09-21 00:24:57
【问题描述】:

这是我的厨房.yml

---
driver:
  name: vagrant
  network:
    - ["private_network", {ip: "192.168.35.35"}]

provisioner:
  name: chef_zero
  # You may wish to disable always updating cookbooks in CI or other testing environments.
  # For example:
  #   always_update_cookbooks: <%= !ENV['CI'] %>
  always_update_cookbooks: true
  roles_path: test/integration/roles/

verifier:
  name: inspec

platforms:
  - name: ubuntu-14.04

suites:
  - name: default
    run_list:
      - role[tomcat_role]
    verifier:
      inspec_tests:
        - test/smoke/default
    attributes:

我不断收到以下错误

    [2017-04-24T10:39:02+00:00] ERROR: Role tomcat_role (included by 'top lev
el') is in the runlist but does not exist. Skipping expand.

       =========================================================================
=======
       Error expanding the run_list:
       =========================================================================
=======

       Missing Role(s) in Run List:
       ----------------------------
       * tomcat_role included by 'top level'

角色肯定存在于厨师服务器上,但我仍然收到此错误。是不是不能在kitchen.yml的run list属性中使用role?

【问题讨论】:

  • Chef Server 无关紧要,因为您使用的是本地配置器,但是您将测试角色放在什么路径中?
  • json 文件 (tomcat.json) 位于 test/integration/roles 文件夹 roles_path: test/integration/roles/ 更新帖子。
  • 我应该将我的 json 文件保存在任何特定位置吗?
  • 如果你调用角色文件tomcat.json,那么你不应该在test-kitchen中将它称为tomcat_role。 IIRC 文件名很重要。
  • 我试过了。我的 json 文件名是 tomcatrole ,json 中的名称字段也是 tomcatrole 并且在 kitchen.yml 中我也有 tomcatrole run_list: - "role[tomcatrole]"

标签: chef-infra test-kitchen


【解决方案1】:

如 cmets 中所述,角色的文件名必须匹配其 name 字段,并且必须匹配运行列表中的 role[name] 字符串。确保所有这三个对齐,你应该都准备好了。

【讨论】:

  • 我试过了。我的 json 文件名为 tomcatrole ,json 中的名称字段也是 tomcatrole 并且在 kitchen.yml 中我也有 tomcatrole run_list: - "role[tomcatrole]"
【解决方案2】:

好的,问题出在 roles_paths 上。我将其更改为role_path,一切正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-11
    • 1970-01-01
    • 2016-12-15
    • 1970-01-01
    • 2011-02-12
    • 1970-01-01
    相关资源
    最近更新 更多