Skip to content
This repository has been archived by the owner on Dec 26, 2017. It is now read-only.

chef solo doesn't update shared folder #17

Closed
minasmart opened this issue Apr 10, 2013 · 22 comments · Fixed by #232 or #233
Closed

chef solo doesn't update shared folder #17

minasmart opened this issue Apr 10, 2013 · 22 comments · Fixed by #232 or #233

Comments

@minasmart
Copy link

When I run vagrant up all cookbooks are updated in the appropriate ~/.berkshelf/vagrant/berkshef-* directory, but when I make a change to a cookbook and run vagrant provision the cookbooks aren't updated. If I runt vagrant halt followed by vagrant up the cookbooks are updated again. Is there a hook missing for the vagrant provision task? I'm using the fusion provider if that helps.

Thanks!

@johntdyer
Copy link
Contributor

what version of vagrant and berkshelf-vagrant?

@minasmart
Copy link
Author

vagrant 1.1.5
berkshelf-vagrant 1.0.6

And the vagrant-vmware-fusion provider (0.4.2)

@ivey
Copy link
Contributor

ivey commented Apr 19, 2013

Please try again with vagrant-berkshelf 1.2.0 and see if it's fixed. (Yes, we renamed it. You can uninstall berkshelf-vagrant.)

@kiall
Copy link

kiall commented May 2, 2013

This is still an issue with vagrant-berkshelf 1.2.0, vagrant 1.2.2, using the.. LXC provider ;) version 0.3.3

@icambron
Copy link

icambron commented May 4, 2013

vagrant-berkshelf 1.2.0, vagrant 1.2.2, virtualbox, same issue. I picked a bad month to try out Berkshelf; took me forever to realize this wasn't my fault.

@reset
Copy link
Contributor

reset commented May 8, 2013

@icambron could you set the environment variable VAGRANT_LOG=info, run vagrant up, and post the results to a gist here?

Thanks!

@icambron
Copy link

icambron commented May 9, 2013

@reset, just to confirm, you want the results of vagrant up, not vagrant provision?

@mikelococo
Copy link

I'm experiencing this bug as well, also using vagrant-lxc as the provider instead of the default virtualbox provider. The following gist contains:
a - Info level output of a vagrant provision run that fails.
b - (Truncated) info level output of a vagrant up run that succeeds.
https://gist.github.com/mikelococo/5580301

If you 'vagrant ssh' into the guest after vagrant up and 'ls /tmp/vagrant-chef-1/chef-solo-1/cookbooks/' you will see all the relevant cookbooks have been loaded onto the guest. If you do so after a vagrant provision run, there are no cookbooks in that directory at all... it's completely empty.

Not positive if this is a bug in berkshelf, or if vagrant-lxc is violating some contract that a provider is supposed to fulfill... but it sounds like some folks are experiencing it with the vmware-fusion provider as well.

Version info:
$ vagrant --version
Vagrant version 1.2.2

$ vagrant plugin list
vagrant-berkshelf (1.2.0)
vagrant-lxc (0.3.4)

@fgrehm
Copy link

fgrehm commented May 15, 2013

hey guys, @mikelococo pointed out to this issue to me on twitter and I'm willing to help those having a hard time getting this plugin to play well with vagrant-lxc.
I'm a Puppet user and I've never used chef / berkshelf before, so it would be awesome if someone could point me to a sample repo or gist that reproduces the problem in order for me to debug what's going on :-)

@ivey
Copy link
Contributor

ivey commented May 15, 2013

@fgrehm Hello! Here's where we hook into provision: https://github.com/RiotGames/vagrant-berkshelf/blob/master/lib/berkshelf/vagrant/plugin.rb#L7

Do you use ::Vagrant::Action::Builtin::Provision or a different action?

@fgrehm
Copy link

fgrehm commented May 15, 2013

@ivey yup, I'm using the builtin action over there too. are you guys by any chance trying to mount new shared folders after the machine is up? right now vagrant-lxc requires shared folders to be defined before bringing the machine up as they are passed on as an argument to lxc-start

@mikelococo
Copy link

@fgrehm You had asked for a repo that can repro the issue. I've created a hello-worldy cookbook that uses berkshelf just to pull in and run opscodes apt cookbook:

https://github.com/mikelococo/demo-berkshelf-17

Instructions for use are in the readme, or ping me in this bug or on twitter for support working through the chef toolchain.

@fgrehm
Copy link

fgrehm commented May 15, 2013

@mikelococo tks a lot for taking the time to put this up :-) I'll look into it ASAP

@sethvargo
Copy link
Contributor

Using VMWare Fusion,

An initial vagrant provision will pull in the cookbooks. However, any modifications to cookbooks thereafter (including a version bump) will use the old version.

My current workaround was to vagrant halt and then vagrant up, which forces a reload of the repo.

@tmatilai
Copy link
Contributor

@sethvargo Do you have the latest version of vagrant-vmware-fusion plugin? That sounds like #24 that was fixed in v0.6.2.

@sethvargo
Copy link
Contributor

@tmatilai yea. and newest version.

@tmatilai
Copy link
Contributor

Ah yeah, now I understand the issue. Sorry for the noise.

@fgrehm
Copy link

fgrehm commented May 15, 2013

Hey guys, I think I've got a fix for this, the problem seems to be on berkshelf itself. I'll try to send a PR for it tonight or tomorrow :)

@fgrehm
Copy link

fgrehm commented May 16, 2013

Hey guys, I've just sent a PR to Berkshelf which should fix this issue (at least for the lxc provider), for those willing to try it out, you can monkey patch Berkshelf::Berksfile from within your Vagrantfile by adding the code below at the top of it:

module Berkshelf
  class Berksfile
    def self.vendor(cookbooks, path)
      chefignore = nil
      path       = File.expand_path(path)
      scratch    = Berkshelf.mktmpdir

      FileUtils.mkdir_p(path)

      unless (ignore_file = Berkshelf::Chef::Cookbook::Chefignore.find_relative_to(Dir.pwd)).nil?
        chefignore = Berkshelf::Chef::Cookbook::Chefignore.new(ignore_file)
      end

      cookbooks.each do |cb|
        dest = File.join(scratch, cb.cookbook_name, "/")
        FileUtils.mkdir_p(dest)

        # Dir.glob does not support backslash as a File separator
        src = cb.path.to_s.gsub('\\', '/')
        files = Dir.glob(File.join(src, "*"))

        # Filter out files using chefignore
        files = chefignore.remove_ignores_from(files) if chefignore

        FileUtils.cp_r(files, dest)
      end

      # This is the patch!
      FileUtils.rm_r Dir.glob("#{path}/*"), force: true, secure: true
      FileUtils.mv Dir.glob("#{scratch}/*"), path
      FileUtils.remove_dir(scratch, force: true)

      path
    end
  end
end

@mikelococo
Copy link

I tested via the Vagrantfile monkey patch described above, which fixes the issue with no side effects that I can observe. I look forward to seeing this merged and released.

@fgrehm Thanks for looking into this even though you're not a chef user. Having vagrant-lxc be fully compatible with berkshelf is much appreciated.

@ivey
Copy link
Contributor

ivey commented May 29, 2013

Update: we're going to be re-working how we update existing vendor directories, moving towards a full tree-traversal with add/remove. This is targeted for 3.0.

In the meantime, if we want berkshelf/berkshelf#525 to come in, we'll need some tests around it. @sethvargo also had a few concerns about hidden files.

@tisba
Copy link

tisba commented Mar 2, 2014

berkshelf/berkshelf#525 was closed some time ago, but I'm still having the issue discussed here. @fgrehm's patch fortunately works, but that looks rather fragile to me and I'm wondering what can be done to fix this issue.

@berkshelf berkshelf locked and limited conversation to collaborators Jun 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet