How to install ansible-playbook on windows as host with vagrant - vagrant

I am trying to orchestrate server with LEMP stack and other configuration. For this I'm using vagrant to up(manage) servers and Ansible for auto configuration and package installations. I'm using windows as host machine where ansible need to be installed and all *Nix machine would be guest which are going to be configured.
With pip I have successfully installed ansible in C:\Python27\Scripts
I am facing Problem in running ansible and ansible-playbook on windows. If any one has done this for windows machine, Please share article or way to accomplish.
http://www.azavea.com/blogs/labs/2014/10/running-vagrant-with-ansible-provisioning-on-windows/
I had gone through above article but its not working, Error
==> default: Running provisioner: ansible...
zsh:1: no such file or directory: /bin/ansible-playbook
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
In *Nix as guest all working excellent. But looking for support to do same in windows machine.

Using windows as the control machine is not supported. But you can have a pleasant experience using docker with boot2docker.
This will install a virtualbox VM guest on the windows machine, which you will be able to use to configure you vagrant boxes, for which you will have to configure the networking properly.

You can achieve this with cygwin. For scripts to do this have a look at:
https://github.com/taliesins/win-ansible
As an added bonus it adds the shims required to use Ansible from windows command prompt and from Vagrant.

From the documentation:
Currently Ansible can be run from any machine with Python 2 (version 2.7) or Python 3 (versions 3.5 and higher) installed. Windows isn’t supported for the control machine.
Generally speaking, if you are using a Windows host, you have 3 options. Listed in order of (my) preference:
Run Ansible from a Docker container
Run Ansible from WSL (if you're running on Windows 10). This Gist can help you with some further setup so that you don't have to invoke WSL to run Ansible.
Run Ansible from Cygwin

Related

Ansible Playbook to create an unattended install of Ubuntu in VM

I've been trying to create a playbook to do an unattended install of Ubuntu server 18.04.2 using an iso on VmWare.
The playbook will actually create the instance but stops and waits for user input to select the language, keyboard config, etc.
How can I get ansible/vmware to use a preseed.cfg file to set those options so I can create an unattended install?
Thanks!
You might be starting with the wrong tool.
Eventually, you will use Ansible, but calling it from Packer.
Start here: https://github.com/geerlingguy/packer-boxes

How to run Ansible playbooks on Redhat Linux from Windows CLI?

I have a project where I have a cluster of Linux Redhat hosts, however I want to run a playbook through my Windows Command Prompt. I have checked out the documentation on their official website, but I didn't see much about my approach. I know it may not be conventional or smart to run it from a Windows CLI but I want to see if I could do it. I tried one line of code below:
Command:
ansible-playbook -i hosts playbook.yml
Using a stock windows machine as a control node is not supported.
There are however 2 options that will let you run ansible from windows:
Running from cygwin
Running from wsl (windows 10).

Use Windows with Virtual Box as Host and VM guest for managing with Vagrant and Ansible

Is there a way for next scenario as I am planing to setup lab environment:
physical desktop running Windows 8 platform
on Windows 8, I plan to install ONLY Virtual Box 5.1
then on VirtualBox to setup CentOS system
and then on CentOS will be running Vagrant and Ansible (no VirtualBox installation)
Question: Is there any way that this setup will work to create new environments via CentOS as Vagrant-Ansible manage servers?
------------------------edit----------------------
Thank you for your answer. I try to setup as I mentioned above without luck. I am new user of Vagrant and Ansible so I am having trouble to make it work. I setup Linux system on VB, install vagrant, install Ansible but when I hit 'vagrant up' I am getting error that "No usable default provider could be found for your". I am following documentation form official sites but can;t make it work. Then I try to install VirtualBox inside Linux system and now it is working but defined machines with Vagrant installs inside Linux machine (where are Vagrant and Ansible installed) and not on Host VirtualBox. Any advice? I hope it is clearer now. Thanks
I have had some success in using a Windows Ansible Host and running using Vagrant with this host.
I have scripted how to setup Win Ansible and the shims at:
https://github.com/taliesins/win-ansible
The important bit is to setup shims that call bash scripts running under cygwin.
Another important thing to consider is, is that it is probably better to generate your own inventory file (put it in the vagrant file before you create VMs) then to use an auto-generated inventory file.
If you environment is not simple consider not using Vagrant provisioner for Ansible, but rather call Ansible via command line at the end of the vagrant file (after you have created the VMs).

Why Rethinkdb don't have binary for windows?

I am interested in Rethinkdb and would like to develop/test on it, but main problem is: it don't have package for windows operating system. I tried to compile from source code, that was also not possible as there was no any instruction.
What makes it so difficult to make executable for windows? Is there any alternative way to install Rethinkdb in windows OS? even very small and not that famous application has windows binary but not Rethinkdb. It is quite surprise for me. Another surprising is there are many community executable for other OS but not windows.
Thank you for understanding and waiting for good answer.
Rethinkdb just announced that it started development for Windows. Please follow
[1] https://github.com/rethinkdb/rethinkdb/issues/1100
[2] https://twitter.com/segphault/status/590633792781611009
Update:
RethinkDB announced in Windows :
[3] https://rethinkdb.com/docs/install/windows/
Cross-platform development isn't that easy. RethinkDB uses some features under the covers which makes porting it to Windows a difficult job, f.e. a Unix toolchain for the builds and Unix syscalls. For more information on that have a look at this GitHub issue. It states that Windows support is planned, but with low priority.
As a quick fix, you could RethinkDB run in a virtual machine or in Microsoft Azure. For the second one, I wrote a blog post a few weeks ago.
RethinkDB has already started development for Windows. While it's not released yet, this is how you can run it through Vagrant. See: https://github.com/gearz-lab/rethinkdb-vagrant
I'm using Chocolatey, feel free to skip steps if they don't apply.
Installing Chocolatey
Open Powershell as an administrator and run this command:
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
... now you should have Chocolatey installed. We're gonna use to install the others.
Installing Vagrant
Run this as an administrator:
choco install vagrant -y
Installing VirtualBox
Vagrant relies on a virtualization application that it calls a "provider". The default one is VirtualBox so let's install it. Run cmd as administrator and run this:
choco install virtualbox -y
Now you should be able to run the vboxmanage command. If it doesn't work, make sure C:\Program Files\Oracle\VirtualBox is in your PATH.
Installing Cygwin
We're gonna log on a virtual machine using SSH, so we need a SSH enabled terminal. For that, let's use Cygwin.
choco install cyg-get -y
Installing Cygwin packages
There'are two Cygwin packages we need to install, openssh, because Cygwin doesn't have SSH support by default, and rsync so Vagrant can use it to synchronize files between the host and the guest machines.
On PowerShell, running as an administrator, let's run these commands:
cyg-get openssh
cyg-get rsync
Cloning rethinkdb-vagrant
Open the Cygwin64 Terminal. You should now be in your Cygwin home folder, which should look like C:\tools\cygwin\home\[YOUR_USER].
Make sure you have git installed. If you don't just choco install git -y. Now, clone rethyinkdb-vagrant:
git clone https://github.com/gearz-lab/rethinkdb-vagrant.git
Now you should have a directory like this: C:\tools\cygwin\home\[YOUR_USER]\rethinkdb-vagrant.
Starting Vagrant and useful commands
From inside the Cygwin64 Terminal home directory (described in the last step), type cd rethinkdb-vagrant, now, any Vagrant commands will target cd rethinkdb-vagrant.
To setup and boot the machine: vagrant up (After this, RethinkDB is available, see next step).
To access the machine's terminal: vagrant ssh.
To destroy the machine (every RethinkDB data will be lost): vagrant destroy.
To suspend the machine: vagrant suspend.
To resume a suspended machine: vagrant resume.
Accessing RethinkDB.
Make sure you have vagrant up from the last step. Now:
For accessing the web administration tool: http://localhost:8080.
For accessing RethinkDB from a client app, the port is 28015.

Windows 8 HOST Vagrant spinup GUEST Ubuntu dev followed with Ansible manage dev stack from GUEST

I am working with Vagrant to provision Ubuntu servers using bash. I would like to cut my teeth on Ansible however I understand that Ansible does not currently run on Windows Host.
Is something like the following a reasonable work-around?
On Windows Host, use Vagrant to spin-up a basic Ubuntu Dev Box, including Ansible tools. From the Guest Dev Box use Ansible to run local tasks to further build it out. From the Dev Box I would use Ansible to spin-up/manage other Digital Ocean droplets from this Dev Box.
Your easiest workaround is probably to use virtualbox to start a linux/ubuntu virtual running on your Windows box, then to run Vagrant inside of that virtual. Yes, it's turtles all the way down- windows running virtualbox+ubuntu running virtualbox+ubuntu+vagrant.
Of course, the first layer won't be managed by Vagrant or Ansible, though you could do most of the configuration management after bootstrapping it.
Another option is to have a small dev box in your virtual hosting provider (Digital Ocean) where you manually install and launch vagrant/ansible from.
Alternately, dual boot or switch to a Linux or OSX machine :)

Resources