无法找到外部食谱,Vagrant和Chef Solo

时间:2015-11-30 19:57:28

标签: vagrant chef chef-solo

我继承了一个未在几年内部署的项目。它最初设置为使用Chef在Vagrant机器上进行本地部署。

当我运行vagrant up命令时,我收到错误,它没有找到一些食谱。首先,它没有在Vagrantfile中指定的cookbook目录中找到cookbook。我通过在我试图运行的食谱中添加metadata.rb文件来修复此问题。它看起来像

#cookbooks/app/metadata.rb
depends "openssl"  # this is in the cookbooks directory
depends "build-essential" # this in the cookbooks directory
depends "git" # this in the cookbooks directory 

现在当我运行vagrant up时,它会在git cookbook中断,因为它找不到它的依赖项dmg(我甚至不需要)。

那么如何安装这些cookbooks依赖项以便它能够运行。这些烹饪书应该安装在我的主机(即我的装有Vagrant盒子的Mac)上还是安装在Vagrant上。  我已经下载了ChefDK并拥有Berkshelf,但我不确定如何在现有项目中使用它。同样基于solo.rb文件,它似乎正在寻找/etc/chef/cookbooks中的食谱。

# solo.rb
log_level :info
cookbook_path "/etc/chef/cookbooks"
json_attribs "/etc/chef/cookbooks/node_staging.json"
role_path "/etc/chef/roles"

以下是运行vagrant up的示例输出。

==> default: Running chef-solo...
==> default: stdin: is not a tty
==> default: [2015-11-30T19:46:31+00:00] INFO: Forking chef instance to converge...
==> default: [2015-11-30T19:46:31+00:00] WARN:
==> default: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
==> default: SSL validation of HTTPS requests is disabled. HTTPS connections are still
==> default: encrypted, but chef is not able to detect forged replies or man in the middle
==> default: attacks.
==> default:
==> default: To fix this issue add an entry like this to your configuration file:
==> default:
==> default: ```
==> default:   # Verify all HTTPS connections (recommended)
==> default:   ssl_verify_mode :verify_peer
==> default:
==> default:   # OR, Verify only connections to chef-server
==> default:   verify_api_cert true
==> default: ```
==> default:
==> default: To check your SSL configuration, or troubleshoot errors, you can use the
==> default: `knife ssl check` command like so:
==> default:
==> default: ```
==> default:   knife ssl check -c /tmp/vagrant-chef/solo.rb
==> default: ```
==> default:
==> default: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
==> default: Starting Chef Client, version 11.18.12
==> default: [2015-11-30T19:46:31+00:00] INFO: *** Chef 11.18.12 ***
==> default: [2015-11-30T19:46:31+00:00] INFO: Chef-client pid: 1844
==> default: [2015-11-30T19:46:32+00:00] INFO: Setting the run_list to ["role[vagrant]"] from CLI options
==> default: [2015-11-30T19:46:32+00:00] INFO: Run List is [role[vagrant]]
==> default: [2015-11-30T19:46:32+00:00] INFO: Run List expands to [app::default]
==> default: [2015-11-30T19:46:32+00:00] INFO: Starting Chef Run for geosurvey
==> default: [2015-11-30T19:46:32+00:00] INFO: Running start handlers
==> default: [2015-11-30T19:46:32+00:00] INFO: Start handlers complete.
==> default: Compiling Cookbooks...
==> default:
==> default: Running handlers:
==> default: [2015-11-30T19:46:32+00:00] ERROR: Running exception handlers
==> default: Running handlers complete
==> default:
==> default: [2015-11-30T19:46:32+00:00] ERROR: Exception handlers complete
==> default: [2015-11-30T19:46:32+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: Chef Client failed. 0 resources updated in 1.06392657 seconds
==> default: [2015-11-30T19:46:32+00:00] ERROR: Cookbook dmg not found. If you're loading dmg from another cookbook, make sure you configure the dependency in your metadata
==> default: [2015-11-30T19:46:32+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.

2 个答案:

答案 0 :(得分:1)

Vagrant本身并不支持Berkshelf集成。有一个可用的插件(vagrant-berkshelf),它将引入依赖关系并将它们同步到VM,但不推荐它,因为它可能有点不稳定。测试厨房(kitchen-vagrant)通常更容易。您也可以使用berks vendor命令手动执行此操作以下载deps并将其转储到chef-solo可以使用的文件夹结构中。

答案 1 :(得分:0)

我有类似的问题并成功解决了他们的聚会。 安装vagrant berkshelf插件解决了它的派对。据我所知,必须通过每个食谱和类型吠声安装appart从配置vagrant barkshelf像这样:

config.berkshelf.enabled = true
config.berkshelf.berksfile_path = "./cookbooks/database/Berksfile"

但我正在探索这种供应商解决方案并不能很好地运作。 据我所知,如果我有一个名为" ./ cookbooks-source"的目录,我理解为coderanger。并且在其中有一堆食谱(cb1,cb2,cb3,...)我将不得不迭代它们并键入类似

的内容
berks vendor ../../cookbooks

然后这些烹饪书中的每一个都可能会相互冲突?另外我觉得很不方便。同时探索berks包,但不知道如何将它与流浪者联系起来。

相关问题