测试厨师角色和环境

编程入门 行业动态 更新时间:2024-10-23 23:34:10
本文介绍了测试厨师角色和环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是Chef的新手,并且一直使用测试厨房来测试我的菜谱的有效性,效果很好。现在,我要确保在最初运行Chef之前,特定于环境的属性在生产节点上是正确的。这些将在角色中定义。

I'm new to Chef and have been using Test Kitchen to test the validity of my cookbooks, which works great. Now I'm trying to ensure that environment-specific attributes are correct on production nodes prior to running Chef initially. These would be defined in a role.

例如,我有一些食谱可以使用带有开发人员设置的Vagrant框来收敛,从而验证食谱。我希望能够测试生产节点的角色。我想我希望这些测试成为描述我的环境的真实来源。看看Test Kitchen的文档,这似乎超出了范围。

For example, I may have recipes that converge using a Vagrant box with dev settings, which validates the cookbook. I want to be able to test that a production node's role. I think I want these tests as the source of truth describing my environment. Looking at Test Kitchen's documentation, this seems beyond its scope.

我的假设正确吗?在第一次在生产节点上运行Chef之前,是否有更好的方法来测试菜谱以确保它具有正确的设置?

Is my assumption correct? Is there a better approach to test a cookbook before the first time Chef is run on a production node to ensure it has the correct settings?

推荐答案

我很高兴地发现Chef_zero在其厨师存储库中使用了 test / integration目录。

I pleasantly discovered that chef_zero uses the "test/integration" directory as it's chef repository.

只需在

  • 测试/集成/角色

标准厨师食谱布局。

├── attributes │   └── default.rb ├── Berksfile ├── Berksfile.lock ├── chefignore ├── .kitchen.yml ├── metadata.rb ├── README.md ├── recipes │   └── default.rb └── test └── integration ├── default │   └── serverspec │   ├── default_spec.rb │   └── spec_helper.rb └── roles └── demo.json

.kitchen.yml

.kitchen.yml

--- driver: name: vagrant provisioner: name: chef_zero platforms: - name: ubuntu-14.04 suites: - name: default run_list: - role[demo] attributes:

注意:

  • 供应商是Chef_zero
  • 运行列表配置为使用角色
file "/opt/helloworld.txt" do content "#{node['demo']['greeting']}" end

属性/默认值。 rb

attributes/default.rb

default['demo']['greeting'] = "hello world"

注意:

  • 没有默认值
require 'spec_helper' describe file('/opt/helloworld.txt') do it { should be_file } its(:content) { should match /this came from my role/ } end

注意:

  • 集成测试正在寻找由角色设置的内容属性
{ "name": "demo", "default_attributes": { "demo": { "greeting": "this came from my role" } }, "run_list": [ "recipe[demo]" ] }

更多推荐

测试厨师角色和环境

本文发布于:2023-11-06 21:38:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564740.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:厨师   角色   环境   测试

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!