vovimayhem / vagrant-guest_ansible

Running Ansible in Vagrant Guests
MIT License
67 stars 29 forks source link

Config option to replace :ansible provisioner with :ansible_guest? #2

Closed tknerr closed 9 years ago

tknerr commented 9 years ago

Considering the typical use case that you are using this plugin to make vagrant / ansible provisioning available to windows users, it would be nice if there were less repetition in the Vagrantfile.

Eg. instead of:

Vagrant.configure("2") do |config|
  if Vagrant::Util::Platform.windows?
    config.vm.provision :guest_ansible do |ansible|
      ansible.playbook = "any_playbook.yml"
    end
  else
    config.vm.provision :ansible do |ansible|
      ansible.playbook = "any_playbook.yml"
    end
  end
end

Rather something like that:

Vagrant.configure("2") do |config|
  config.ansible_guest.replace =  Vagrant::Util::Platform.windows?
  # can keep the single provision block - will be replaced with ansible_guest under the hood
  config.vm.provision :ansible do |ansible|
    ansible.playbook = "any_playbook.yml"
  end
end

Does this make sense?

I'm not sure because there might be some config options (e.g. paths) which are specific to either host or guest...

tknerr commented 9 years ago

Anyhow you can get quite far with this today already, e.g.:

Vagrant.configure("2") do |config|
  provisioner =  Vagrant::Util::Platform.windows? ? :ansible : :ansible_guest
  config.vm.provision provisioner do |ansible|
    ansible.playbook = "any_playbook.yml"
  end
end
tknerr commented 9 years ago

Btw: my assumption is that the config options are in sync with the original :ansible provisioner, are they?

vovimayhem commented 9 years ago

Frankly you caught me off-guard with this one, let me check what can I do...

PR's are always welcome, BTW!

tknerr commented 9 years ago

@vovimayhem thanks for taking you time to look at it! I just wanted to capture the idea and put it on for discussion. I'm not sure whether there is so much added value in it, given the workaround mentioned above. Mostly wanted to hear your opinion on it... :-)

As for the PRs - yes, definitely. For now I only skimmed the README and it looks promising. I will give it a try next week. Once I'm on it, and I see need for things being improved, I might be in for PRs as well :-)