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

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).

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

Fabric-Composer on Windows 10 linux sub system?

Has anyone succeeded in running fabric-composer on windows 10 linux sub-system running ubuntu 16.04 ?
You can run composer on windows 10 WSL (windows Subsystem for linux) but you will not be able to run docker containers in it. Linux Docker containers require a linux kernel and WSL doesn't have a linux kernel. It is a clever piece of technology that converts user space Linux API calls dynamically to windows API calls.
Therefore you will have to run hyperledger fabric either by using docker for windows (which runs it for you in hyper-v) or you run your own hypervisor.
It is possible to have the docker commands run in WSL but it will need to configure it to interact with the docker daemon running inside a hypervisor.
Yes, you can use Hyperledger-fabric-composer on windows 10, but as david said in above answer you will not be able to run docker containers directly from Ubuntu sub-system.
To do that you have to do following things:
METHOD:- 1
You will need to install docker CE Client & docker-compose in Ubuntu Subsystem and install Docker(version v17.09) on Windows as well. But those dockers won’t connect together out of the box.
So you need to expose the daemon to port 2375 first by right-clicking the docker icon on task-bar then click setting then check the Expose daemon box.
Now the docker server will be able to connect via Windows network including Ubuntu subsystem. We need to set environment variables in Ubuntu by running below command:
echo "export DOCKER_HOST='tcp://0.0.0.0:2375'" >> ~/.bashrc
source ~/.bashrc
These commands will add DOCKER_HOST to the variables every time we start a new Bash.
METHOD:- 2
If you don't want to use ubuntu sub-system, then you can simply install Git Bash and Docker(version v17.09).
Then install Hyperledger-Fabric by using Git Bash.

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).

How to install ansible-playbook on windows as host with 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

Run a windows xp bat script remotely from a ubuntu machine

Is it possible to run a windows xp bat script remotely from a ubuntu machine via command line?
This is possible if you have an ssh server running on the WinXP machine. It is trivial to set up such a server if you have installed Cygwin. This is well described here.
Then from an Ubuntu command line (or cron job) you run
ssh user#winxp command
Make sure your .bat has executable permissions.
I think that the technology you are after is WMI. I see that there is an ubuntu package called wmi-client, which you can sudo apt-get install and attempt to you. Some quick searches and I'm unable to find details, but maybe that will get you somewhere....
You would probably use something like remote desktop, and if you did it that way, it would work, but your question isn't very specific

Resources