Ansible on Ubuntu - ansible

I have created two Ubuntu machines on virtual box. I am able to ping the other machine from the terminal of the other.
However when I ping from ansible I get the following error.
My /etc/ansible/hosts file is :
Can I get the solution for this ?

If you read the documentation you will notice:
This is NOT ICMP ping
So the way in which the ping command works and the way in which Ansible module works is different.
Reading further, Ansible ping module is described as:
Try to connect to host, verify a usable Python and return pong on success.
So Ansible tries to connect (and the default connection method is SSH) and execute Python code.
In your case Ansible failed to connect.
SSH connectivity is a prerequisite, so you need to configure that before you'll be able to use Ansible. For Ubuntu 16.04 you might need to additionally install OpenSSH.
Refer to the official guide for the installation and configuration steps.
On top of that, Ubuntu Server 16.04 does not install Python 2 by default, so you need to manually add it (Ansible support for Python 3 is still experimental).
Refer to answers under this question on AskUbuntu.
Then you still might need to set a parameter in the inventory file to tell Ansible to use Python 2. Or make Python 2 the default interpreter.

Related

Ansible -m Setup filter option not working for Windows hosts?

This command works on localhost (Ubuntu):
ansible localhost -m setup -a 'filter=ansible_*_mb'
When I try run this againts my Windows group, the filtering doesnt seem to work, as I always receive the full output. Is this a known limitation?
Yes, filter in setup module is not supported for Windows targets.
Referring to the Documentation of setup module,
If the target host is Windows, you will not currently have the ability
to use filter as this is provided by a simpler implementation of the
module.

Vagrant box setup

I am trying to setup Hyperledger fabric on my Windows 7 machine. I installed all the prerequisite for environment setup like: Go, Oracle VM, Vagrant.
I cloned the fabric folder from hyperledger site. While trying to run vagrant up, it throws me error like:
connection aborted ,Retrying ....
It took SSH user name as: ubuntu and SSH password: password
I followed the steps from link1 and link2 for my setup.
Can any one suggest me how to solve this problem?
It would be great help for me if anyone share some solutions.
Please find the error screenshot for your reference.
Have you tried the docker setup? Seems to be the recommenced development environment.
To answer your question, Vagrant wants to use SSH keys for password-less access by default. Your Vagrantfile should point to SSH keys to use. Since you're on Windows you may need to generate these keys.

How to restart Ansible host machine on Linux?

I've installed Ansible host on my RHEL Linux machine.
I made some configurations changes and I want to restart it but I can't find how it's being done.
I used this manual for installation.
Checking running services I don't see an Ansible service.
How can I restart Ansible?
*NOTE: I installed Ansible from source files.
Ansible is not a service, it is an executable program (actually a few executables) which is called, starts, and ends its execution.
There is no way to restart Ansible other than calling it again. The changes in configuration will be reflected on the next run.
Also: there is no "Ansible host" component. "Ansible control machine" is a general term for the machine you run Ansible executables on.
Similarly Ansible-Pull is also not a service, but a script which is scheduled externally.
try
ps -ef|grep ansible
to double check that there is no ansible service or daemon.

Is there any Ansible remote client for control machine?

Ansible unlike chef and puppet uses agent less run .
I would like to know is there any ansible remote client so that we can connect to fleet of ansible control machines to execute ansible playbooks on their respective targets .
I am looking for a command line cliient similar to following
ansible-execute hostname_of_control_machine username_of_control_machine password_of_control_machine inventory_file playbook_name
Please suggest if any ?
There is nothing preventing you from using Ansible to run Ansible on other machines. The Python API might be a good place to start, as you can get programmatic control over the initial Ansible runner.
You can do this with SSH
ssh username#controlmachine 'ansible-playbook yourPlaybook.yml

Configure TCP endpoint when vagrant up or reload

I'm using Vagrant to run an Ubuntu VM with Microsoft Azure provider, but I need to create an endpoint on this VM.
I've done it installing azure command-line tools with
npm install azure-cli -g
and after that
azure vm endpoint create {VM-Name} 80 8080
VM is running fine without problems. But I don't want to configure the endpoint manually anymore. I would like to create it when I run vagrant up. I don't want to use vagrant provision, because this shell instruction should not be executed in my VM, but in my physical machine.
There is no options such as verbose in vagrant, which would have permitted me to see what it really does with the Vagrantfile, and what I should do to implement a shell command like this one in it.
Ansver to initial question, do the following:
in vagrantfile add following string in azure provider section:
azure.tcp_endpoints = '80:8080'
hope this help.
answer to your question about verbose output:
you may run vagrant up --provider=azure --debug
for additional debug information.
if you need to run local scripts you may try to use vagrant-triggers plugin

Resources