Windows host support with Ansible provisioning

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Windows host support with Ansible provisioning

Warren Seine
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.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Windows host support with Ansible provisioning

Gilles Cornu
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

Le mercredi 18 février 2015 10:23:06 UTC+1, Warren Seine a écrit :
Hi,

Ansible doesn't support Windows as a host. However, a <a href="https://github.com/geerlingguy/JJG-Ansible-Windows" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fgeerlingguy%2FJJG-Ansible-Windows\46sa\75D\46sntz\0751\46usg\75AFQjCNFvOCg9sr3SlwsrpdNwNuNLd2MvNA';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fgeerlingguy%2FJJG-Ansible-Windows\46sa\75D\46sntz\0751\46usg\75AFQjCNFvOCg9sr3SlwsrpdNwNuNLd2MvNA';return true;">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.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Windows host support with Ansible provisioning

Torben Knerr
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


On Wed, Feb 18, 2015 at 2:13 PM, Gilles Cornu <[hidden email]> wrote:

> 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
>
> Le mercredi 18 février 2015 10:23:06 UTC+1, Warren Seine a écrit :
>>
>> 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.
>
> --
> 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Windows host support with Ansible provisioning

Warren Seine-2
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.

On Wed, Feb 18, 2015 at 10:01 PM, Torben Knerr <[hidden email]> wrote:
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


On Wed, Feb 18, 2015 at 2:13 PM, Gilles Cornu <[hidden email]> wrote:
> 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
>
> Le mercredi 18 février 2015 10:23:06 UTC+1, Warren Seine a écrit :
>>
>> 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.
>
> --
> 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 [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Warren Seine


Founder and CTO of Aerys | aerys.in
Phone: (+33)9 72 28 55 82  /  (+33)6 79 51 64 66

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Windows host support with Ansible provisioning

Warren Seine-2
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. 

On Thursday, February 19, 2015 at 11:16:12 AM UTC+1, Warren Seine wrote:
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.

On Wed, Feb 18, 2015 at 10:01 PM, Torben Knerr <[hidden email]> wrote:
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:
<a href="https://gist.github.com/tknerr/291b765df23845e56a29" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Ftknerr%2F291b765df23845e56a29\46sa\75D\46sntz\0751\46usg\75AFQjCNEClsQfNjLaqTjJg4yxBxjQZ6YhQQ';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgist.github.com%2Ftknerr%2F291b765df23845e56a29\46sa\75D\46sntz\0751\46usg\75AFQjCNEClsQfNjLaqTjJg4yxBxjQZ6YhQQ';return true;">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 [hidden email].
For more options, visit https://groups.google.com/d/optout.