使用Chef安装Postgres在Vagrant VM上的问题:未定义方法`ruby’用于Config:Module

这就是我的Vagrantfile样子:

  config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "cookbooks" chef.json = { postgresql: { password: { postgres: 'password' } }, database: { create: ['mydb'] }, 'build-essential' => { compiletime: true } } chef.run_list = ['recipe[build-essential]', 'recipe[openssl]', 'recipe[postgresql::server]', 'recipe[database::postgresql]'] end 

我也使用了precise32盒子。 当我的虚拟机启动后我的VM启动vagrant up ,我会得到很长的回溯,并显示错误消息: undefined method ruby’用于Config:Module`。

有没有人遇到过这个?

安装“pg”gem似乎有问题:

 ================================================================================ Error executing action `install` on resource 'chef_gem[pg]' ================================================================================ Gem::Installer::ExtensionBuildError ----------------------------------- ERROR: Failed to build gem native extension. /opt/vagrant_ruby/bin/ruby extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config checking for libpq-fe.h... yes checking for libpq/libpq-fs.h... yes .. .. checking for st.h... yes creating extconf.h creating Makefile make sh: 1: make: not found 

我建议阅读build-essentials cookbook的文档。 它建议设置“compiletime”属性以支持确保构建工具可用于编译RubyGems扩展。

更新1

以下json设置对我有用:

 chef.json = { "postgresql" => { "password" => { "postgres" => "password" } }, "database" => { "create" => ["encased_dev"] }, "build_essential" => { "compiletime" => true } } 

注意:

  • 属性是“build_essential”而不是“build-essential”

更新2

我后来发现有一个ruby配方也解决了这个问题(通过设置构建必需节点属性)。 将其添加到运行列表或使用数据库cookbook