Hack: berkshelf 1.3 and vagrant 1.0


#1

I had so many issues with upgrading Vagrant that I decided to go back
to 1.0 for now. I needed Berkshelf integration. I could not get the
"new" berkshelf-vagrant to work with vagrant 1.0, but that may be just
me.

So, here’s my hack that others may find helpful - if only as comedic relief:


#2

I managed to get the upgrade working, was a little bit of a struggle.

General Steps

  1. Install new Vagrant DMG (on mac)
  2. Uninstall Vagrant Gem (from system, rvm, bundler whatever)
  3. Install Berkshelf Vagrant Plugin (vagrant plugin install berkshelf-vagrant)
  4. Upgrade Berkshelf Gem to 1.3.*
  5. Rerun Berks install
  6. Remove any ‘require Berkshelf’ sections from my Vagrantfile
  7. Remove references to ‘config.berkshelf.berksfile_path’ from Vagrantfile

Notes:
vagrant up seems to not do a vagrant provision automatically, so now I
have to chain the commands.

The .vagrant file is now actually a folder, so make sure to use rm -rf to
clean up afterwards.

Granted my Vagrantfiles are very simple, so there may be more conversion
needed.

Andrew

On Tue, Mar 26, 2013 at 10:09 AM, Brian Akins brian@akins.org wrote:

I had so many issues with upgrading Vagrant that I decided to go back
to 1.0 for now. I needed Berkshelf integration. I could not get the
"new" berkshelf-vagrant to work with vagrant 1.0, but that may be just
me.

So, here’s my hack that others may find helpful - if only as comedic
relief:

https://github.com/bakins/berkshelf-hobo


#3

We use multi-vm vagrant setups quite a bit and berkshelf-vagrant
doesn’t support that (yet). We also have some other tooling around
vagrant and berkshelf that broke. This was just a hack until we had
the time to get everything “fixed” and I thought others may be in the
same situation.


#4

I see. It’s certainly not a super smooth transition yet.

On Tue, Mar 26, 2013 at 4:13 PM, Brian Akins brian@akins.org wrote:

We use multi-vm vagrant setups quite a bit and berkshelf-vagrant
doesn’t support that (yet). We also have some other tooling around
vagrant and berkshelf that broke. This was just a hack until we had
the time to get everything “fixed” and I thought others may be in the
same situation.


#5

I still cannot get vagrant provision to work with chef-solo. I followed
your upgrade steps below, and then ran …

vagrant up
vagrant provision

On the up command it brings up the vagrant box as expected.
On the provision step, it invokes the berkshelf plugin to download all
the cookbooks as defined the Berksfile to some isolated directory for
this vagrant box. But then when it runs the actual chef-solo run, it
cannot find any cookbooks. Am I missing something here? Shouldn’t the
berkshelf plugin somehow be injecting the path or creating a shared
folder to the isolated download directory so chef-solo in the VM can
find its cookbooks?

On 2013-03-26 12:08 PM, Andrew Gross wrote:

I managed to get the upgrade working, was a little bit of a struggle.

General Steps

  1. Install new Vagrant DMG (on mac)
  2. Uninstall Vagrant Gem (from system, rvm, bundler whatever)
  3. Install Berkshelf Vagrant Plugin (vagrant plugin install berkshelf-vagrant)
  4. Upgrade Berkshelf Gem to 1.3.*
  5. Rerun Berks install
  6. Remove any ‘require Berkshelf’ sections from my Vagrantfile
  7. Remove references to ‘config.berkshelf.berksfile_path’ from Vagrantfile

Notes:
vagrant up seems to not do a vagrant provision automatically, so
now I have to chain the commands.

The .vagrant file is now actually a folder, so make sure to use rm
-rf to clean up afterwards.

Granted my Vagrantfiles are very simple, so there may be more
conversion needed.

Andrew

On Tue, Mar 26, 2013 at 10:09 AM, Brian Akins <brian@akins.org
mailto:brian@akins.org> wrote:

I had so many issues with upgrading Vagrant that I decided to go back
to 1.0 for now. I needed Berkshelf integration.  I could not get the
"new" berkshelf-vagrant to work with vagrant 1.0, but that may be just
me.

So, here's my hack that others may find helpful - if only as
comedic relief:

https://github.com/bakins/berkshelf-hobo

#6

Hmm, Berkshelf should make the cookbooks discoverable. I have not had that
specific issue. How is Chef installed in your VM? Via the omnibus
embedded style? Or via a gem. I am curious if that might affect it. Also,
is this for windows or linux?

On Thu, Mar 28, 2013 at 9:58 AM, Mark Pimentel markpimentel22@gmail.comwrote:

I still cannot get vagrant provision to work with chef-solo. I followed
your upgrade steps below, and then ran …

vagrant up
vagrant provision

On the up command it brings up the vagrant box as expected.
On the provision step, it invokes the berkshelf plugin to download all the
cookbooks as defined the Berksfile to some isolated directory for this
vagrant box. But then when it runs the actual chef-solo run, it cannot
find any cookbooks. Am I missing something here? Shouldn’t the berkshelf
plugin somehow be injecting the path or creating a shared folder to the
isolated download directory so chef-solo in the VM can find its cookbooks?

On 2013-03-26 12:08 PM, Andrew Gross wrote:

I managed to get the upgrade working, was a little bit of a struggle.

General Steps

  1. Install new Vagrant DMG (on mac)
  2. Uninstall Vagrant Gem (from system, rvm, bundler whatever)
  3. Install Berkshelf Vagrant Plugin (vagrant plugin install berkshelf-vagrant)
  4. Upgrade Berkshelf Gem to 1.3.*
  5. Rerun Berks install
  6. Remove any ‘require Berkshelf’ sections from my Vagrantfile
  7. Remove references to ‘config.berkshelf.berksfile_path’ from Vagrantfile

Notes:
vagrant up seems to not do a vagrant provision automatically, so now I
have to chain the commands.

The .vagrant file is now actually a folder, so make sure to use rm -rf
to clean up afterwards.

Granted my Vagrantfiles are very simple, so there may be more conversion
needed.

Andrew

On Tue, Mar 26, 2013 at 10:09 AM, Brian Akins brian@akins.org wrote:

I had so many issues with upgrading Vagrant that I decided to go back
to 1.0 for now. I needed Berkshelf integration. I could not get the
"new" berkshelf-vagrant to work with vagrant 1.0, but that may be just
me.

So, here’s my hack that others may find helpful - if only as comedic
relief:

https://github.com/bakins/berkshelf-hobo


#7

Hi Mark,

I had a similar problem and it turned out to be the way my client was
abstracting their box configuration similar to the following :

Vagrant.configure(“2”) do |config|
config.vm.box_url =
"http://mirrors.example.com/vagrant/boxes/ubuntu-12.04-x86_64.box"
config.vm.synced_folder “srv”, “/srv”, “/srv”

config.vm.define :mybox do |mybox_config|
mybox_config.vm.box = “mybox.dev”

<snip but everything defined around mybox_config (instead of just config)>

end
end

Instead of just using a more standard setup like :

Vagrant.configure(“2”) do |config|

config.vm.box_url =
"http://mirrors.example.com/vagrant/boxes/ubuntu-12.04-x86_64.box"
config.vm.synced_folder “/srv”, “/srv”, :nfs => true

config.vm.box = “mybox.dev”

config.vm.network :private_network, ip: "192.168.12.23"
config.vm.network :forwarded_port, guest: 22, host: 2322

<snip - all other definitions etc.>

end

Having the extra abstraction for mybox_config prevented berkshelf from
working correctly for some reason. Changing to the standard way fixed
my problem.

Thought it was worth mentioning in case your Vagrantfile is similarly setup.

Cheers

adh

Andrew Hollingsworth
adh@techopsguru.com

On Thu, Mar 28, 2013 at 6:58 AM, Mark Pimentel markpimentel22@gmail.com wrote:

I still cannot get vagrant provision to work with chef-solo. I followed
your upgrade steps below, and then ran …

vagrant up
vagrant provision

On the up command it brings up the vagrant box as expected.
On the provision step, it invokes the berkshelf plugin to download all the
cookbooks as defined the Berksfile to some isolated directory for this
vagrant box. But then when it runs the actual chef-solo run, it cannot find
any cookbooks. Am I missing something here? Shouldn’t the berkshelf plugin
somehow be injecting the path or creating a shared folder to the isolated
download directory so chef-solo in the VM can find its cookbooks?

On 2013-03-26 12:08 PM, Andrew Gross wrote:

I managed to get the upgrade working, was a little bit of a struggle.

General Steps

  1. Install new Vagrant DMG (on mac)
  2. Uninstall Vagrant Gem (from system, rvm, bundler whatever)
  3. Install Berkshelf Vagrant Plugin (vagrant plugin install berkshelf-vagrant)
  4. Upgrade Berkshelf Gem to 1.3.*
  5. Rerun Berks install
  6. Remove any ‘require Berkshelf’ sections from my Vagrantfile
  7. Remove references to ‘config.berkshelf.berksfile_path’ from Vagrantfile

Notes:
vagrant up seems to not do a vagrant provision automatically, so now I
have to chain the commands.

The .vagrant file is now actually a folder, so make sure to use rm -rf to
clean up afterwards.

Granted my Vagrantfiles are very simple, so there may be more conversion
needed.

Andrew

On Tue, Mar 26, 2013 at 10:09 AM, Brian Akins brian@akins.org wrote:

I had so many issues with upgrading Vagrant that I decided to go back
to 1.0 for now. I needed Berkshelf integration. I could not get the
"new" berkshelf-vagrant to work with vagrant 1.0, but that may be just
me.

So, here’s my hack that others may find helpful - if only as comedic
relief:

https://github.com/bakins/berkshelf-hobo


#8

I just ran through a Berksfile test and am seeing the same thing. I
changed one thing in the Vagrant file and that was to use a local
centos6.3 box I already had instead of downloading another box.
Otherwise it was plain vanilla Berkshelf with only the local cookbook I
was testing, no external deps.

To fix:
I added into the Vagrantfile: chef.cookbooks_path =
"/Users/sascha/pathto/cookbooks" to the provisioning section and that
fixed it.

I’ve had the same problem with test-kitchen’s vagrant plugin as well so
I’m wondering if there’s something different with new Vagrant and how
it’s doing cookbook path discovery?

Andrew Hollingsworth mailto:adh@techopsguru.com
March 28, 2013 1:06 PM
Hi Mark,

I had a similar problem and it turned out to be the way my client was
abstracting their box configuration similar to the following :

Vagrant.configure(“2”) do |config|
config.vm.box_url =
"http://mirrors.example.com/vagrant/boxes/ubuntu-12.04-x86_64.box"
config.vm.synced_folder “srv”, “/srv”, “/srv”

config.vm.define :mybox do |mybox_config|
mybox_config.vm.box = “mybox.dev”

<snip but everything defined around mybox_config (instead of just config)>

end
end

Instead of just using a more standard setup like :

Vagrant.configure(“2”) do |config|

config.vm.box_url =
"http://mirrors.example.com/vagrant/boxes/ubuntu-12.04-x86_64.box"
config.vm.synced_folder “/srv”, “/srv”, :nfs => true

config.vm.box = “mybox.dev”

config.vm.network :private_network, ip: "192.168.12.23"
config.vm.network :forwarded_port, guest: 22, host: 2322

<snip - all other definitions etc.>

end

Having the extra abstraction for mybox_config prevented berkshelf from
working correctly for some reason. Changing to the standard way fixed
my problem.

Thought it was worth mentioning in case your Vagrantfile is similarly
setup.

Cheers

adh

Andrew Hollingsworth
adh@techopsguru.com

Mark Pimentel mailto:markpimentel22@gmail.com
March 28, 2013 8:58 AM
I still cannot get vagrant provision to work with chef-solo. I
followed your upgrade steps below, and then ran …

vagrant up
vagrant provision

On the up command it brings up the vagrant box as expected.
On the provision step, it invokes the berkshelf plugin to download all
the cookbooks as defined the Berksfile to some isolated directory for
this vagrant box. But then when it runs the actual chef-solo run, it
cannot find any cookbooks. Am I missing something here? Shouldn’t
the berkshelf plugin somehow be injecting the path or creating a
shared folder to the isolated download directory so chef-solo in the
VM can find its cookbooks?

On 2013-03-26 12:08 PM, Andrew Gross wrote:

Andrew Gross mailto:andrew@yipit.com
March 26, 2013 11:08 AM
I managed to get the upgrade working, was a little bit of a struggle.

General Steps

  1. Install new Vagrant DMG (on mac)
  2. Uninstall Vagrant Gem (from system, rvm, bundler whatever)
  3. Install Berkshelf Vagrant Plugin (vagrant plugin install berkshelf-vagrant)
  4. Upgrade Berkshelf Gem to 1.3.*
  5. Rerun Berks install
  6. Remove any ‘require Berkshelf’ sections from my Vagrantfile
  7. Remove references to ‘config.berkshelf.berksfile_path’ from Vagrantfile

Notes:
vagrant up seems to not do a vagrant provision automatically, so
now I have to chain the commands.

The .vagrant file is now actually a folder, so make sure to use rm
-rf to clean up afterwards.

Granted my Vagrantfiles are very simple, so there may be more
conversion needed.

Andrew

Brian Akins mailto:brian@akins.org
March 26, 2013 9:09 AM
I had so many issues with upgrading Vagrant that I decided to go back
to 1.0 for now. I needed Berkshelf integration. I could not get the
"new" berkshelf-vagrant to work with vagrant 1.0, but that may be just
me.

So, here’s my hack that others may find helpful - if only as comedic
relief:

https://github.com/bakins/berkshelf-hobo