I have a vagrant file that uses chef to help install things:
Vagrant.configure(2) do |config|
config.vm.box = 'opscode-ubuntu-12.04_chef-11.4.0'
config.vm.box_url = 'https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_chef-11.4.0.box'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.provider(:virtualbox) do |vb|
vb.customize [
"modifyvm", :id,
"--memory", "1024",
"--cpus", "4"
]
end
config.vm.provision :shell, inline: %Q{
sudo apt-get install -y postgresql-client
}
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = ["cookbooks"]
chef.add_recipe :apt
chef.add_recipe 'postgresql::server'
chef.add_recipe 'build-essential'
chef.add_recipe 'rvm::vagrant'
chef.add_recipe 'rvm::system'
chef.add_recipe 'git'
chef.json = {
:postgresql => {
:version => '9.3'
},
"postgresql" => {
"password" => {
"postgres" => "kshgfi3ret3hihjfbkivtbo3ity835"
}
},
"database" => {
"create" => ["aisisplatform"]
},
:git => {
:prefix => "/usr/local"
},
:rvm => {
'rubies' => [ 'ruby-2.1.0' ],
'default_ruby' => 'ruby-2.1.0',
'vagrant' => {
:system_chef_solo => '/usr/bin/chef-solo'
}
},
}
end
end
There are a few issues with this:
Through out the
vagrant up
start up I get warnings like this:/tmp/vagrant-chef-1/chef-solo-1/cookbooks/rvm/libraries/rvm_chef_user_environment.rb:32: warning: class variable access from toplevel
The next issue is that things don't work properly, some times the vm sees PostgreSQL, through the
psql
command, sometimes it doesn't know what it is and states it's not installed. when it does see it, it states thatpsql: FATAL: role "vagrant" does not exist
The final issue is that when the vm boots up there is well over 200 updates of both regular and security. I would like this to be taken care of when the vm is set up the first time, via
vagrant up
. I tried doing:config.vm.provision :shell, inline: %Q{ sudo apt-get update sudo apt-get upgrade -y }
But when the script runs I get TON of errors about stdn
and so on and so forth. So, what do I do to fix these? what's wrong with my vagrant file?