问题
That's how my Vagrantfile
looks :
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
Also I used precise32
box.
And while my VM starts after vagrant up
, I get very long traceback with error message: undefined method
ruby' for Config:Module`.
Does anybody encountered this?
回答1:
There appears to be a problem installing the "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
I suggest reading the documentation of the build-essentials cookbook. It suggests setting the "compiletime" attribute in order to support to ensure that the build tools are available to compile RubyGems extensions.
Update 1
The following json settings worked for me:
chef.json = {
"postgresql" => {
"password" => {
"postgres" => "password"
}
},
"database" => {
"create" => ["encased_dev"]
},
"build_essential" => {
"compiletime" => true
}
}
Note:
- Attribute is "build_essential" and not "build-essential"
Updated 2
I have since discovered that there is a ruby recipe that fixes this issue as well (by setting the build essential node attributes about). Either add it to your run-list or use the database cookbook
- https://github.com/opscode-cookbooks/database/blob/master/recipes/postgresql.rb
来源:https://stackoverflow.com/questions/18287581/issue-with-installing-postgres-on-vagrant-vm-using-chef-undefined-method-ruby