forklift icon indicating copy to clipboard operation
forklift copied to clipboard

Overriding plugin options does not seem to work

Open mattiascockburn opened this issue 7 years ago • 3 comments

Heya,

trying to override some (hard-coded) defaults for the vagrant-hostmanager plugin here. I am using forklift as a library, which is documented here I want to use it, but not necessarily want to update the Hosts /etc/host file. So i tried the following:

  1. Create a plugins/custom-plugins/Vagrantfile in the root of my repo with the following contents:
module CustomPlugins
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if Vagrant.has_plugin?("vagrant-vbguest")
      config.vbguest.enabled = false
    end
    if Vagrant.has_plugin?("vagrant-hostmanager")
       config.hostmanager.enabled = true
       config.hostmanager.manage_host = false
    end
  end
end 
  1. Create a link to this file inside of forklift/plugins (ln -s ../../my-custom-plugins .)
  2. vagrant up a machine and observe that the overrides are ignored. The file does not seem to get loaded at all. If i manually comment the relevant parts in box_distributor.rb it will work.

Is this the right[TM] way of doing things or am i on a completely wrong path? I would like to use forklift as a general boiler-plate for my vagrant environments and need to override certain plugin options depending on the environment i am working with.

mattiascockburn avatar Sep 19 '17 09:09 mattiascockburn

I think https://github.com/theforeman/forklift/blob/c10243609452845993cdf0a95e39f887e2f5474b/lib/forklift/box_distributor.rb#L108-L114 overrides this anyway disregarding your changes. That can't currently be overridden and would need a patch.

ekohl avatar Oct 17 '17 09:10 ekohl

@mattiasgiese I think the broader solution might be to make the hostmanager options configurable at the box level similar to how other things like memory/cpu/etc. are. Would that solve your problem?

ehelms avatar Feb 28 '18 02:02 ehelms

Well, yeah, making all relevant parameters configurable (not only hostmanager but other used plugins as well) would certainly help me.

mattiascockburn avatar Feb 28 '18 03:02 mattiascockburn