Windows host support with Ansible provisioning

165 views
Skip to first unread message

Warren Seine

unread,
Feb 18, 2015, 4:23:06 AM2/18/15
to vagra...@googlegroups.com
Hi,

Ansible doesn't support Windows as a host. However, a documented workaround is to run ansible locally through a script in the guest.

I usually add:

    is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)

    if is_windows
      # Provisioning configuration for shell script.
      local.vm.provision "shell" do |s|
        s.path = "bootstrap.sh"
        s.args = ["provisioning/#{action}.yml", "provisioning/inventory", "local"]
      end
    else
      # Provisioning configuration for Ansible (for Mac/Linux hosts).
      local.vm.provision "ansible" do |ansible|
        ansible.sudo = true
        ansible.playbook = "provisioning/#{action}.yml"
        ansible.inventory_path = "provisioning/inventory"
        ansible.verbose = "vv"
        ansible.limit = "local"
      end
    end

to my Vagrantfile and it works (obviously not the same as native support but ok).

I'm sure Vagrant could do it on its own if this was part of the Ansible provisioning. Would it make sense?

Regards,
Warren.

Gilles Cornu

unread,
Feb 18, 2015, 8:13:40 AM2/18/15
to vagra...@googlegroups.com
Hi Warren,

The new guest-based provisioner "ansible_local" is coming, see https://github.com/mitchellh/vagrant/pull/5340.

Note Vagrant users still will have to decide/configure how to combine "ansible" and/or "ansible_local" provisioners.

Feedbacks welcome!

Best,
Gilles

Torben Knerr

unread,
Feb 18, 2015, 4:02:17 PM2/18/15
to vagra...@googlegroups.com
Hi Gilles, Warren,

nice, did not know about this PR yet, looks nice!

In the meantime these are the two approaches which work well for me:
https://gist.github.com/tknerr/291b765df23845e56a29

The first one uses the vagrant-guest_ansible provisioner, the second
one starts a dedicated VM and starts provisioning from there

Cheers,
Torben
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Warren Seine

unread,
Feb 19, 2015, 5:16:12 AM2/19/15
to vagra...@googlegroups.com
I wouldn't want to spawn a new VM for that, but your plugin approach looks good. Trying it right now, and hoping the best for the PR.

You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/WtHYWGz4U8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vagrant-up+...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Warren Seine


Founder and CTO of Aerys | aerys.in

Warren Seine

unread,
Feb 19, 2015, 5:51:32 AM2/19/15
to vagra...@googlegroups.com
Not working for me.

The plugin doesn't interpret inventory_path in a correct way (takes the inventory file instead, and doesn't care if it's in a directory). It breaks my workflow.

I couldn't fix it so I will report the issue on the PR.

Keeping my old way of doing it anyway. 
Reply all
Reply to author
Forward
0 new messages