Vagrant Chef VM help


#1

Hi,

I set up virtual machine with help of Vagrant. Also set up Chef - basic
stuff so it has folder for cookbooks but it ended under tmp folder
instead of usr and building apache2 failed

I don’t know why… Followed Vagrant docs

Here it is what I put under Vagrantfile

Vagrant::Config.run do |config|
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = [“cookbooks”, [:vm, “/usr/local/cookbooks”]]
chef.add_recipe "apache2"
chef.add_role "web"
end
end

But before complete boot of my VM I got this error

– v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -t vboxsf -o uid=id -u vagrant,gid=id -g vagrant v-csc-1
/tmp/vagrant-chef-1/chef-solo-1/cookbooks

Is it possible to edit cookbooks under tem so I don’t have to destroy VM
every single time and re-edit Vagrantfile?

I am a noob here. So, if you would be so kind and help me to resolve this

Also, if you have any good tutorial how do I set up Virtual machine in a
way that when I ssh to it I see which role that VM has… For example that
it has base role

Thanks


#2

Hi there,

Until you actually get a chef run going, there’s no harm in simply running
"vagrant provision" (once you’ve unsuccessfully run “vagrant up”) on that
VM. I suggest you simplify your Vagrantfile a bit by changing this line:

chef.cookbooks_path = [“cookbooks”, [:vm, “/usr/local/cookbooks”]]

to:

chef.cookbooks_path = [“cookbooks”]

This will tell Vagrant to mount ./cookbooks on the host as a cookbook
path within the guest, so you can edit cookbooks using your favorite editor
and still test them with Vagrant on the guest.

(However, I believe checking in ./cookbooks is Vagrant’s default behavior
… so you can probably lose the line entirely and still get what you want.)

In order to update the message of the day, you’ll need to start using a
Chef handler that does that. Fortunately, there’s one on GitHub …
(“chef-handler-motd” I believe …)

Good luck!

On Tue, Jul 23, 2013 at 8:47 AM, Jasna Benčić jasna.bencic@teamsnap.comwrote:

Hi,

I set up virtual machine with help of Vagrant. Also set up Chef - basic
stuff so it has folder for cookbooks but it ended under tmp folder
instead of usr and building apache2 failed

I don’t know why… Followed Vagrant docs

Here it is what I put under Vagrantfile

Vagrant::Config.run do |config|
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = [“cookbooks”, [:vm, “/usr/local/cookbooks”]]
chef.add_recipe "apache2"
chef.add_role "web"
end
end

But before complete boot of my VM I got this error

– v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -t vboxsf -o uid=id -u vagrant,gid=id -g vagrant v-csc-1
/tmp/vagrant-chef-1/chef-solo-1/cookbooks

Is it possible to edit cookbooks under tem so I don’t have to destroy VM
every single time and re-edit Vagrantfile?

I am a noob here. So, if you would be so kind and help me to resolve this

Also, if you have any good tutorial how do I set up Virtual machine in a
way that when I ssh to it I see which role that VM has… For example that
it has base role

Thanks


#3

Thanks steve for your answer, will work on it

On Wed, Jul 24, 2013 at 7:09 PM, steve . leftathome@gmail.com wrote:

Hi there,

Until you actually get a chef run going, there’s no harm in simply running
"vagrant provision" (once you’ve unsuccessfully run “vagrant up”) on that
VM. I suggest you simplify your Vagrantfile a bit by changing this line:

chef.cookbooks_path = [“cookbooks”, [:vm, “/usr/local/cookbooks”]]

to:

chef.cookbooks_path = [“cookbooks”]

This will tell Vagrant to mount ./cookbooks on the host as a cookbook
path within the guest, so you can edit cookbooks using your favorite editor
and still test them with Vagrant on the guest.

(However, I believe checking in ./cookbooks is Vagrant’s default behavior
… so you can probably lose the line entirely and still get what you want.)

In order to update the message of the day, you’ll need to start using a
Chef handler that does that. Fortunately, there’s one on GitHub …
(“chef-handler-motd” I believe …)

Good luck!

On Tue, Jul 23, 2013 at 8:47 AM, Jasna Benčić jasna.bencic@teamsnap.comwrote:

Hi,

I set up virtual machine with help of Vagrant. Also set up Chef - basic
stuff so it has folder for cookbooks but it ended under tmp folder
instead of usr and building apache2 failed

I don’t know why… Followed Vagrant docs

Here it is what I put under Vagrantfile

Vagrant::Config.run do |config|
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = [“cookbooks”, [:vm, “/usr/local/cookbooks”]]
chef.add_recipe "apache2"
chef.add_role "web"
end
end

But before complete boot of my VM I got this error

– v-csc-1: /tmp/vagrant-chef-1/chef-solo-1/cookbooks
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

mount -t vboxsf -o uid=id -u vagrant,gid=id -g vagrant v-csc-1
/tmp/vagrant-chef-1/chef-solo-1/cookbooks

Is it possible to edit cookbooks under tem so I don’t have to destroy VM
every single time and re-edit Vagrantfile?

I am a noob here. So, if you would be so kind and help me to resolve this

Also, if you have any good tutorial how do I set up Virtual machine in a
way that when I ssh to it I see which role that VM has… For example that
it has base role

Thanks