Ansible ad-hoc solution for collecting network hosts inventory via cli

Outline the use of an Ansible ad-hoc solution for collecting network hosts inventory via cli  on Ubuntu 14.04

This is by no means the most efficient method. I highly recommend learning the ansible playbook methodology I have yet to learn myself. 

ansible http://docs.ansible.com/ansible/playbooks.html

I have not found a way to implicitly change ssh port value via cli.

The solution recommended is to add each host to etc/ansible/hosts accompanied by their respective custom port.

10.0.0.1:1234

To add/remove hosts edit the following.

vi /etc/ansible/hosts
 
The hosts values can be grouped. In this case we are grouping by the root password needed to access the hosts

    [password_list_1]
    10.2.0.2:1234
    10.2.8.7:1234
    [password_list_2]
    10.1.0.3:1234
    10.1.0.17:1234
 
Save and exit the hosts file.

Issue ansible commands like so.
ansible will request the ssh login for that group and proceed to collect host inventory information.

ansible password_list_1 -m setup -u root  -k --tree /tmp/inventory
 
or
 
 ansible password_list_2 -m setup -u root  -k --tree /tmp/inventory


To get a list of failed attempts at fetching the inventory

find /tmp/inventory -size -16b


Comments

Popular posts from this blog

AH00534: apache2: Configuration error: No MPM loaded