Coder Social home page Coder Social logo

ansible-discovery's Introduction

Ansible Discovery

Ansible hosts discovery and filter by operating system.

How this works ?

The Ansible server has a web server and each client has a curl who make a request to the web server every day. The server generate a JSON file for each request from clients and update the timestamp.

JSON file for the hostname client01

{
    "hostname":"client01",
    "os":"centos",
    "time":"2016-05-18 14:30:00"
}

JSON file for the hostname client02

{
    "hostname":"client02",
    "os":"ubuntu",
    "time":"2016-05-18 15:30:00"
}

After the clients make the HTTP request, you can execute the generate-host.py file on the server and this script generate the host list for Ansible.

Ansible host list /etc/ansible/hosts

[centos]
client01

[ubuntu]
client02

Ansible Client

For each client should create a cron task with the command curl to annunce to the Ansible web server.

For example, if your client is an Ubuntu Linux, you can create the next cron task.

* 19 * * * curl --silent http://ansible-server -X POST -d "hostname=`hostname`" -d "os=Ubuntu"

This cron execute every day at 19:00hs, this make an HTTP request method POST, with the hostname and os, as variables.

Ansible Server

Web server

  • Web server root path: /www/
  • Web server root index: /www/index.php
  • Web server JSON file list: /www/hosts/

Cron to generate the /etc/ansible/hosts file

The script generate-host.py generate the file /etc/ansible/hosts for Ansible, the list of hosts are obtained from /www/hosts/, you can create a cron task to execute this script every day.

For example, the task for generate the file of host list is executed at 20:00hs, after the clients are announced.

* 20 * * * /usr/bin/python /root/generate-host.py

ansible-discovery's People

Contributors

dignajar avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.