Ansible Inventory Plugin, created to get hosts from HTTP API.

Overview

Build Dockerfile Build Ansible Collection

augustoliks/ws-inventory Docker Pulls

augustoliks/ws-inventory

ansible-ws-inventory-plugin

Ansible Inventory Plugin, created to get hosts from HTTP API.

Features:

  • Database compatible with MongoDB and Filesystem (JSON format);
  • Import inventory with .CSV file format;
  • Export inventory with .CSV file format.

Diagram

Configure Ansible Inventory Plugin: augustoliks.ws

Requirements

pip3 install requests

Installing the Collection from Ansible Galaxy

Before using the augustoliks.ws collection, you need to install it with the Ansible Galaxy CLI:

ansible-galaxy collection install augustoliks.ws

You can also include it in a requirements.yml file and install it via ansible-galaxy collection install -r requirements.yml, using the format:

---
collections:
  - name: augustoliks.ws
    version: 1.0.3

Usage

Create inventory file ws-iventory.yml, and configure follow options:

# Plugin Name
plugin: augustoliks.ws.inventory

# Plugin Options
api_endpoint: 'http://127.0.0.1:8000/hosts'
timeout: 10

Run Ansible playbook with ws-iventory.yml inventory.

ansible-playbook -i ws-iventory.yml main.yml 

Configure HTTP Server API

Webserver Source code is in the http-server-api/ directory.

Application wrapped in Container Image format, but it can be runs a system wide, with systemd or sysvinit etc.

Pull Docker Image

docker pull augustoliks/ws-inventory:latest

Configuration

Source code was made in Python. The configuration app, using a library dynaconf, for provides multiple formats to configure properties of project. For default, configuration was made in JSON file format, but it could be made from any other source and format compatible with a configuration library.

{
  "filesystem": {
    "BIND_ADDRESS": "0.0.0.0",
    "BIND_PORT": 5000,
    "URI_ROOT_PATH": "/",
    "LOG_LEVEL": "DEBUG",
    "DB_DRIVER": "filesystem",
    "DB_OPTS": {
      "file": "/tmp/inventory.json"
    }
  },
  "mongodb": {
    "BIND_ADDRESS": "0.0.0.0",
    "BIND_PORT": 5000,
    "URI_ROOT_PATH": "/",
    "LOG_LEVEL": "DEBUG",
    "DB_DRIVER": "mongodb",
    "DB_OPTS": {
      "url": "mongodb://root:[email protected]:27017"
    }
  }
}
  • ENV_FOR_DYNACONF: Select high level set properties. Options available: mongodb, filesystem;

  • BIND_ADDRESS: Bind of HTTP Server address uvicorn;

  • BIND_PORT: Port of HTTP Server uvicorn;

  • LOG_LEVEL: Log of application. Levels available: DEBUG, INFO, WARNING, ERROR, CRITICAL;

  • URI_ROOT_PATH: Base URI path routes of webserver (util in reverse proxys servers nginx, apache, traefix);

  • DB_DRIVER: Persistence Tecnology. This option choosed, change properties of DB_OPTS properties. Technologies available: mongodb, filesystem

  • DB_OPTS: Properties access Persist Layer:

    • mongodb:

      • url: URL with basic-auth to access mongodb instance
    • filesystem:

      • file: Path of file which will be used with database.

Example Complete

cd examples/
  • Install dependencies (require virtualenv):
virtualenv venv
source venv/bin/activate
pip3 install -r requirements.txt
ansible-galaxy collection install -r requirements.yml
  • Provides ws-inventory and mongodb container instances:
docker-compose pull
docker-compose up -d
  • Insert hosts:

drawing

  • List hosts:

drawing

  • Check playbook-main.yml properties:

⚠️ augustoliks should be change with your system username.

$ cat playbook-main.yml                                                                                                     

---
- hosts: all
  remote_user: augustoliks
  become_user: augustoliks
  become: yes
  gather_facts: False

  tasks:
    - ansible.builtin.debug:
        var: hostvars
  • Check ws-inventory.yml properties:
$ cat ws-inventory.yml                                                                                                      

plugin: "augustoliks.ws.inventory"
api_endpoint: "http://127.0.0.1:5000/read/hosts"
timeout: 10
  • Test plugin
$ ansible-inventory -i ws-inventory.yml --graph
$ ansible-inventory -i ws-inventory.yml --list
  • Run playbook
$ ansible-playbook -i ws-inventory.yml playbook-main.yml --ask-pass                                                         

SSH password: 

PLAY [all] ********************************************************************************************************************

TASK [ansible.builtin.debug] **************************************************************************************************
ok: [localhost] => {
    "hostvars": {
        "localhost": {
            ...
            "location": {
                "address": "string",
                "latitude": 35.1234,
                "longitude": 10.1234
            },
            ...
        }
    }
}

PLAY RECAP ********************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0                                                                     
Owner
Carlos Neto
DevOps | IaC | Python Developer
Carlos Neto
API written using Fast API to manage events and implement a leaderboard / badge system.

Open Food Facts Events API written using Fast API to manage events and implement a leaderboard / badge system. Installation To run the API locally, ru

Open Food Facts 5 Jan 07, 2023
A kedro-plugin to serve Kedro Pipelines as API

General informations Software repository Latest release Total downloads Pypi Code health Branch Tests Coverage Links Documentation Deployment Activity

Yolan Honoré-Rougé 12 Jul 15, 2022
Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application.

Flask-Bcrypt Flask-Bcrypt is a Flask extension that provides bcrypt hashing utilities for your application. Due to the recent increased prevelance of

Max Countryman 310 Dec 14, 2022
Flask + marshmallow for beautiful APIs

Flask-Marshmallow Flask + marshmallow for beautiful APIs Flask-Marshmallow is a thin integration layer for Flask (a Python web framework) and marshmal

marshmallow-code 768 Dec 22, 2022
🐞 A debug toolbar for FastAPI based on the original django-debug-toolbar. 🐞

Debug Toolbar 🐞 A debug toolbar for FastAPI based on the original django-debug-toolbar. 🐞 Swagger UI & GraphQL are supported. Documentation: https:/

Dani 74 Dec 30, 2022
Sample project showing reliable data ingestion application using FastAPI and dramatiq

Create and deploy a reliable data ingestion service with FastAPI, SQLModel and Dramatiq This is the source code for the data ingestion service explain

François Voron 31 Nov 30, 2022
Lazy package to start your project using FastAPI✨

Fastapi-lazy 🦥 Utilities that you use in various projects made in FastAPI. Source Code: https://github.com/yezz123/fastapi-lazy Install the project:

Yasser Tahiri 95 Dec 29, 2022
FastAPI CRUD template using Deta Base

Deta Base FastAPI CRUD FastAPI CRUD template using Deta Base Setup Install the requirements for the CRUD: pip3 install -r requirements.txt Add your D

Sebastian Ponce 2 Dec 15, 2021
Keycloak integration for Python FastAPI

FastAPI Keycloak Integration Documentation Introduction Welcome to fastapi-keycloak. This projects goal is to ease the integration of Keycloak (OpenID

Code Specialist 113 Dec 31, 2022
Ansible Inventory Plugin, created to get hosts from HTTP API.

ansible-ws-inventory-plugin Ansible Inventory Plugin, created to get hosts from HTTP API. Features: Database compatible with MongoDB and Filesystem (J

Carlos Neto 0 Feb 05, 2022
MS Graph API authentication example with Fast API

MS Graph API authentication example with Fast API What it is & does This is a simple python service/webapp, using FastAPI with server side rendering,

Andrew Hart 4 Aug 11, 2022
flask extension for integration with the awesome pydantic package

flask extension for integration with the awesome pydantic package

249 Jan 06, 2023
Asynchronous event dispatching/handling library for FastAPI and Starlette

fastapi-events An event dispatching/handling library for FastAPI, and Starlette. Features: straightforward API to emit events anywhere in your code ev

Melvin 238 Jan 07, 2023
Simple example of FastAPI + Celery + Triton for benchmarking

You can see the previous work from: https://github.com/Curt-Park/producer-consumer-fastapi-celery https://github.com/Curt-Park/triton-inference-server

Jinwoo Park (Curt) 37 Dec 29, 2022
Opinionated set of utilities on top of FastAPI

FastAPI Contrib Opinionated set of utilities on top of FastAPI Free software: MIT license Documentation: https://fastapi-contrib.readthedocs.io. Featu

identix.one 543 Jan 05, 2023
🐍Pywork is a Yeoman generator to scaffold a Bare-bone Python Application

Pywork python app yeoman generator Yeoman | Npm Pywork | Home PyWork is a Yeoman generator for a basic python-worker project that makes use of Pipenv,

Vu Tran 10 Dec 16, 2022
Flood Detection with Google Earth Engine

ee-fastapi: Flood Detection System A ee-fastapi is a simple FastAPI web application for performing flood detection using Google Earth Engine in the ba

Cesar Aybar 69 Jan 06, 2023
An alternative implement of Imjad API | Imjad API 的开源替代

HibiAPI An alternative implement of Imjad API. Imjad API 的开源替代. 前言 由于Imjad API这是什么?使用人数过多, 致使调用超出限制, 所以本人希望提供一个开源替代来供社区进行自由的部署和使用, 从而减轻一部分该API的使用压力 优势

Mix Technology 450 Dec 29, 2022
Opentracing support for Starlette and FastApi

Starlette-OpenTracing OpenTracing support for Starlette and FastApi. Inspired by: Flask-OpenTracing OpenTracing implementations exist for major distri

Rene Dohmen 63 Dec 30, 2022
FastAPI backend for Repost

Repost FastAPI This is the FastAPI implementation of the Repost API. Installation Python 3 must be installed and accessible through the use of a termi

PC 7 Jun 15, 2021