chef-infra - 如何在 .kitchen.yml 文件中为 chef_solo provisioner 指定 Recipe 路径?

标签 chef-infra chef-solo test-kitchen

我想在 Test Kitchen 中使用 chef_solo 作为配置器来指定 Recipe 路径。我们目前不使用 Berkshelf 或 chef_zero。

我在 .kitchen.yml 文件中设置了 cookbooks_path,但 chef_solo 供应商似乎忽略了该标志。请参阅下面的堆栈跟踪。

.kitchen.yml

---
driver:
  name: vagrant

provisioner:
  name: chef_solo
  require_chef_omnibus: 11.8.0
  roles_path: '../../roles'
  data_bags_path: '../../data_bags'
  environments_path: '../../environments'
  cookbooks_path: '../cookbooks, ../../site-cookbooks'

堆栈跟踪:

$ kitchen converge analytics-centos-65
-----> Starting Kitchen (v1.2.1)
-----> Converging <analytics-centos-65>...
       Preparing files for transfer
       Resolving cookbook dependencies with Berkshelf 3.2.1...
       Removing non-cookbook files before transfer
       Preparing data bags
       Preparing environments
       Preparing roles
       Transfering files to <analytics-centos-65>
       [2015-01-07T18:07:06+00:00] INFO: Forking chef instance to converge...
       Starting Chef Client, version 11.8.0
       [2015-01-07T18:07:06+00:00] INFO: *** Chef 11.8.0 ***
       [2015-01-07T18:07:06+00:00] INFO: Chef-client pid: 4294
       [2015-01-07T18:07:06+00:00] INFO: Setting the run_list to ["role[default]", "role[test]", "role[development]", "role[etl]", "role[ets]", "role[log_consolidator]"] from JSON
       [2015-01-07T18:07:06+00:00] INFO: Run List is [role[default], role[test], role[development], role[etl], role[ets], role[log_consolidator]]
       [2015-01-07T18:07:06+00:00] INFO: Run List expands to [sysctl::attribute_driver, yum::epel, ad-summos::timezone, ad-summos::ntpd, ad-summos::users, ad-summos::pgpass, ad-summos::fix_adsummos_dir_permissions, ad-summos::ec2-keys, ad-summos::sudo, ad-summos::aws, ad-summos::git, ad-summos::bashrc, ad-summos::setup-additional-adsummos-directories, ad-summos::aws-adsummos-user, ad-summos::denyhosts, ad-summos::p7zip, ad-summos::set_firewall_rules, ad-summos::system-tools, ad-summos::deploy_analytics_code, vsftpd, users::development, ad-summos::setup_hostname, etl::configure_etl, ad-summos::mysql-client, ad-summos::postgresql-devel, etl::pdi-tools-42, etl::create_etl_folders, etl::system-wide-rvm-permissions, etl::user_agent_utils, etl::pgpass-adsummos-user, ets::ets-install, ets::varnish-install, ets::sftp-user, ad-summos::sinatra, log_consolidator::configure_log_consolidator, log_consolidator::log_cron_crontab, log_consolidator::install_consolidator_packages]
       [2015-01-07T18:07:06+00:00] INFO: Starting Chef Run for analytics-centos-65
       [2015-01-07T18:07:06+00:00] INFO: Running start handlers
       [2015-01-07T18:07:06+00:00] INFO: Start handlers complete.
       Compiling Cookbooks...
       [2015-01-07T18:07:06+00:00] ERROR: Running exception handlers
       [2015-01-07T18:07:06+00:00] ERROR: Exception handlers complete
       [2015-01-07T18:07:06+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       Chef Client failed. 0 resources updated
       [2015-01-07T18:07:06+00:00] ERROR: Cookbook sysctl not found. If you're loading sysctl from another cookbook, make sure you configure the dependency in your metadata
       [2015-01-07T18:07:06+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <analytics-centos-65>.
>>>>>> Please see .kitchen/logs/analytics-centos-65.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen/solo.rb --json-attributes /tmp/kitchen/dna.json  --log_level info]
>>>>>> ----------------------

相关: How to specify cookbook path in .kitchen.yml file?

我看到了 sethvargo 关于使用 chef_zero 进行配置的回答,但是我们在 Chef Zero 上被阻止了,因为我们的大量环境和角色是在 Ruby 中配置的,而不是 JSON。 https://github.com/opscode/chef-zero/issues/107 .同样,Berkshelf 比我们在代码迁移 atm 中的位置提前一两次迭代。

有没有办法使用 chef_solo 配置器指定本地 Recipe 路径?

最佳答案

I can't speak for it's place in the yaml. However I was able to get it working using a line in the knife.rb

对我来说听起来不错,但请记住 config.rb从 Chef Client 12.0 开始,现在优先。

文档很好地描述了这一点,但请记住其他人描述的属性:

默认 config.rb 位置:

~/.chef/config.rb

Recipe 路径语法:

cookbook_path ["/full/path/to/repo/cookbooks"]

并重新加载 Chef 进行测试。

关于chef-infra - 如何在 .kitchen.yml 文件中为 chef_solo provisioner 指定 Recipe 路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27826223/

相关文章:

windows - Chef windows_package 守卫存在吗?

当我尝试销毁厨房实例时,Virtualbox 被锁定

testing - 如何为 chef make install 编写测试

ruby - 你如何在 CHEF (ruby) 中创建漂亮的 json

php - 为 OpsWorks php 应用程序服务器堆栈设置 upload_max_filesize

ruby - 在 chef lwrp 中安装、要求和使用 ruby​​ 库

virtual-machine - 你怎么知道chef是否在VM上运行(即vagrant)

automated-tests - 是否可以在不使用任何驱动程序的情况下对服务器运行厨房测试?

rvm - 运行配方 rvm::vagrant 后 Vagrant/Chef-solo 不起作用

ruby - 如何使用 include_recipe 检查 Recipe 是否已被包含?