fgrehm / vagrant-cachier

Caffeine reducer
http://fgrehm.viewdocs.io/vagrant-cachier
MIT License
1.07k stars 111 forks source link

Config override for vagrant-cachier (related to vagrant-aws) #69

Closed scalp42 closed 10 years ago

scalp42 commented 10 years ago

Hi @fgrehm

Following our twitter discussion, I'm opening an issue here as it's easier to keep track.

config.cache.enable [:chef, :apt]

config.cache.enable :apt
config.cache.enable :chef
config.vm.define :aws1 do |zs|
    zs.vm.provider 'aws' do |aws, override|
      override.cache.auto_detect = false # does it actually turn it off?

      #  override.cache.disable = true <-- more explicit
    end

Hopefully it helps other folks too, thanks!

cc @tmatilai

fgrehm commented 10 years ago

Good stuff here, thanks for dropping by :)

How do you actually enable multiple buckets at the same time ?

Good question, for now you need to call config.cache.enable multiple times but it might make sense to add support for arrays as well. I personally only use auto detection so that has never been an issue to me :P

Anyone else has thoughts on this?

How do you actually turn it off for lets say vagrant-aws?

Well, if you enabled a bucket, setting auto_detect to false won't disable it. In that case we need to review our DSL / configs. Anyone have an idea / suggestion on how we could revamp our configs?

tmatilai commented 10 years ago

I use config.cache.enable but haven't found the need to squeeze them to one line. And as #enable also takes an optional opts hash as a second argument, the DSL could get a bit hard. (Even though I'm not sure any bucket supports those opts.)

But as said on Twitter, I almost started yesterday to implement some way to disable the plugin. =) But the yak stack was already too deep, so I didn't even take a closer look how to actually do it. I recently added the same thing to vagrant-proxyconf (tmatilai/vagrant-proxyconf#39), so a similar solution could fit here too.

scalp42 commented 10 years ago

In my case, it would be great to not have to duplicate vagrant-cachier in the case where you have 5 vbox VMs and 1 on AWS.

Duplicating this block, create a lot of verbosity in the Vagrantfile in every virtualbox provider:

zs.cache.auto_detect = false
zs.cache.enable_nfs  = true
zs.cache.scope = :machine
enabled_buckets = [:chef, :apt]
enabled_buckets.each { |bucket| zs.cache.enable bucket }

Having a way to override it in the aws provider would allow to only specify it once and just turn it off where it's not needed.

tmatilai commented 10 years ago

As Vagrantfile is just ruby you can also use methods, lambdas, etc.

See for example my global Vagrantfile (which is not perfect as the configuration in the provider blocks overrides the top level config of project specific Vagrantfiles).

I agree that a way to disable the plugin would be useful. Someone™ just has to implement it. =)

scalp42 commented 10 years ago

Thanks for the Vagrantfile @tmatilai but how do you actually define the VMs if you don't mind sharing.

fgrehm commented 10 years ago

@scalp42 thanks to Vagrant's configuration merging, those values defined for each provider acts as a default. so on each project's Vagrantfile you can config.vm.define your VMs and those values will be inherited. you can even override them as needed per project if that's desired. for more information you can check the "LOAD ORDER AND MERGING" section from http://docs.vagrantup.com/v2/vagrantfile/index.html

@tmatilai you are correct, the opts hash stored inside the bucket's config are not used for anything as of now, I just had a quick look around and it seems that it is not in use. I probably added that for whatever reason on the early days of the plugin but ended up not using it. looking at our "backlog" it looks like that the only thing that could benefit from this would be the support for caching specific folders, but that alone has a lot of potential to be used from a different method (if you or someone has some inputs on this, please share it over there so we keep things focused over here :)


before this start to grow too big, I suggest we split it up into 2 issues, one for discussing support for enabling buckets using an array and another to "force disable" caching.

what do you guys think?

tmatilai commented 10 years ago

Anthony, I'll write you an example what I meant. But only later when I get to laptop. Writing formatted code w/ phone is a pain. =)

tmatilai commented 10 years ago

@scalp42 I was thinking that you could call a method from each config.vm.define block. But as Fábio said, you might instead want to configure cachier for all virtualbox VMs. Like I do in my example. For example:

Vagrant.configure('2') do |config|

  config.vm.provider :virtualbox do |vbox, override|
    override.cache.enable_nfs = true
    override.cache.scope = :machine
    override.cache.enable :apt
    override.cache.enable :chef
    # other vbox config
  end

  config.vm.define "foo" do |foo|
    # ...
  end

  # ...
end
tmatilai commented 10 years ago

@scalp42 And even better to configure cachier globally on your workstation in ~/.vagrant.d/Vagrantfile. Then your project's Vagrantfile doesn't have anything special for it.

scalp42 commented 10 years ago

Sounds good, I've settled with this in the meantime: https://gist.github.com/scalp42/08c0df9bbdb800f68ed2

fgrehm commented 10 years ago

Folks, I'm planing to split it up into 2 issues, one for discussing support for enabling buckets using an array and another to "force disable" caching so that we can stay focused on the stuff that this issue has brought up.

@tmatilai @scalp42 are you guys ok with that?

scalp42 commented 10 years ago

Sounds good!

2013/12/17, Fabio Rehm notifications@github.com:

Folks, I'm planing to split it up into 2 issues, one for discussing support for enabling buckets using an array and another to "force disable" caching so that we can stay focused on the stuff that this issue has brought up.

@tmatilai @scalp42 are you guys ok with that?


Reply to this email directly or view it on GitHub: https://github.com/fgrehm/vagrant-cachier/issues/69#issuecomment-30805526

Anthony Scalisi (415) 518 6360

tmatilai commented 10 years ago

Sure!

fgrehm commented 10 years ago

Thanks! I've just created the 2 issues above that are scheduled to be done until 1.0 :-)