我搜索了 3 周,但没有找到任何真正的答案。
主要目标是节省在 AWS 上部署到生产环境之前在本地测试开发 Chef 说明书的时间。
我发现的只是将 Ubuntu 与 Vagrant 一起使用的一些提示:
- 厨师 - 如何在当地运行食谱
- http://pixelcog.com/blog/2015/simplify-opsworks-dev-with-packer/
有没有人经历过与 Centos 来宾一起在本地运行厨房,并使用 JSON(Chef 节点配置(作为节点环境(如在 opsworks 中(的 Chef食谱存储库?
我的.kitchen.yml
文件和树目录:
---
driver:
# specifies the software that manages the machine. We're using the Vagrant Test Kitchen driver
name: vagrant
provisioner:
# specifies how to run Chef. We use chef_zero because it enables you to mimic a Chef server environment on your local machine. This allows us to work with node attributes and other Chef server feature
name: chef_zero
environments_path: './env' # JSON file (node config) is not used !: env/preprod.json
client_rb:
environment: preprod
verifier:
# specifies which application to use when running automated tests. You'll learn more about automated testing in a future module.
name: inspec
platforms:
- name: centos-7
suites:
- name: default
run_list:
# list of cookbooks
- recipe[nginx::default]
attributes:
没有存储库内容的树,没有所有文件,只有目录名称:
(缩小(
├── foobar-cookbooks
│ ├── agent_version
│ ├── apache2
│ │ └── templates
│ │ ├── default
│ ├── foobar
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── recipes
│ │ └── templates
│ │ └── default
│ ├── foobar_app_akeneo
│ │ ├── definitions
│ │ ├── metadata.rb
│ │ └── templates
│ │ └── default
│ ├── foobar_app_drupal
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── templates
│ ├── foobar_app_joomla
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── metadata.rb
│ │ └── recipes
│ ├── Config
│ ├── dependencies
│ │ ├── attributes
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── deploy
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── ebs
│ │ ├── attributes
│ │ ├── files
│ │ │ └── default
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── gem_support
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── haproxy
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── README.rdoc
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── LICENSE
│ ├── memcached
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── mod_php5_apache2
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── mysql
│ │ ├── attributes
│ │ ├── files
│ │ │ └── default
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── nginx
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── metadata.rb
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── opsworks_agent_monit
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ ├── default
│ ├── opsworks_aws_flow_ruby
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── templates
│ │ └── default
│ ├── opsworks_berkshelf
│ │ ├── attributes
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── providers
│ │ ├── recipes
│ │ └── resources
│ ├── opsworks_bundler
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── opsworks_cleanup
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── opsworks_commons
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── providers
│ │ ├── recipes
│ │ └── resources
│ ├── opsworks_custom_cookbooks
│ │ ├── attributes
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── opsworks_ecs
│ │ ├── attributes
│ │ ├── files
│ │ │ └── default
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── templates
│ │ └── default
│ ├── opsworks_ganglia
│ │ ├── attributes
│ │ ├── files
│ │ │ └── default
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── opsworks_initial_setup
│ │ ├── attributes
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── opsworks_java
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ ├── amazon
│ │ ├── default
│ ├── opsworks_nodejs
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── opsworks_rubygems
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── opsworks_shutdown
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── opsworks_stack_state_sync
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── templates
│ │ └── default
│ ├── packages
│ │ ├── attributes
│ │ ├── libraries
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── passenger_apache2
│ │ ├── attributes
│ │ ├── definitions
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── php
│ │ ├── attributes
│ │ │ └── default.rb
│ │ ├── recipes
│ │ ├── specs
│ │ └── templates
│ │ └── default
│ ├── Rakefile
│ ├── README.md
│ ├── ruby
│ │ ├── attributes
│ │ ├── metadata.rb
│ │ ├── recipes
│ │ └── specs
│ ├── scm_helper
│ ├── ssh_host_keys
│ ├── ssh_users
│ ├── test_suite
├── attributes
├── Berksfile
├── chefignore
├── definitions
├── env
├── layers.json
├── metadata.rb
├── recipes
├── spec
├── specs
├── test
"使用测试厨房管理测试环境 尽管您可以在生产环境中启动 Chef 代码之前在专用服务器上对其进行测试,但在运行代码时,Chef 将对服务器的配置进行更改。
在开发过程中测试 Chef 代码的一个明智方法是设置一个与生产环境非常相似的沙盒环境。这将为您提供一个安全的地方来测试您的厨师食谱。Chef 附带 Test Kitchen,可帮助您创建用于测试的沙盒环境。Test Kitchen利用Vagrant和Virtual Box来完成它的工作。
Test Kitchen在Vagrant上运行,您可以在Test Kitchen之上创建沙盒环境。Test Kitchen 作为 Chef 开发工具包的一部分安装,如果您使用的是 Chef Client,则需要单独安装它。
要使用测试厨房创建虚拟环境,请使用厨房创建命令:
$ kitchen create default-centos65
这个例子展示了如何创建一个运行 CentOS 的虚拟环境。此命令下载 Vagrant 基础框,并配置和启动 VM 实例。Test Kitchen 将拉出 Chef Software 通过 VagrantCloud 在互联网上提供的基础盒 最后一个命令创建的 CentOS 实例将设置一个准系统 CentOS 安装,其中包含足够让 Chef 运行的东西。
你可以这样登录到 CentOS 虚拟机:
$ kitchen login default-centos65
Last login: Fri May 28 10:41:48 2016
from 10.0.1.1
欢迎使用 Packer 构建的虚拟机。 在此测试厨房支持的沙盒环境中运行所有测试 Chef 代码。
测试厨房使用YAML文件格式作为其配置文件。YAML 文件处理两种类型的数据——键值对和列表。现代 Linux 管理。