Coder Social home page Coder Social logo

ansible-api's Introduction

Ansible API

This is a really really simple API for Ansible written in Flask. It's meant to be lightweight and used in a distrubted manner to bring scale to Ansible and the capability to make REST based requests to a host.

The code is not meant for production use in its current state. Its missing functions to protect your system from misuse.

If you are looking for a fully fledged API, take a look at the AWX project.

This Flask app lets you look at your roles via the API, and lets you run playbooks via the API

To get started

  sudo pip install flask
  git clone https://github.com/donnydavis/ansible-api.git
  cd ansible-api
  python ansibleapi.py

An example role is included to run a test to ensure the system is functioning

curl --request POST \
  --url http://127.0.0.1:8080/api/run/ \
  --data 'role=test' \
  --data 'play=hello.yml' \
  --data 'host=localhost'

The role parameter relates to the directory your role is in

The play parameter is the Ansible playbook you want to run

The host parameter is the host you want to run the play against

If you want to view the available roles, it looks like this

curl --request GET \
  --url http://127.0.0.1:8080/api/roles/

The json output is configurable in the settings.py file

Ansible API can also fetch roles from github. Support for arbitary git repos will be in the next release.

curl --request POST \
  --url http://127.0.0.1:8080/api/roles/github/get \
  --data 'username=donnydavis' \
  --data 'role=ansible-rh-subscription-manager'

The instructions for how to operate the POST methods of the API are in the GET methods.

If you are unsure of how to run a POST, then do a GET on the same API and an example will be printed for you

curl --request GET \
  --url http://127.0.0.1:8080/api/roles/github/get

Thanks for checking out Ansible API

ansible-api's People

Contributors

donnydavis avatar dustin-cowles 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.