Web-UI to run Ansible Playbook
Web-Interface to run Ansible Playbook
Ansijet
Ansijet is a node.js server which exposes a simple web API which triggers playbook runs when a request is received. This is especially useful if you are unable to run Ansible playbooks directly from within your continuous integration environment or if you simply wish to trigger playbook runs based on other events within your system (may be on a click of a button).
Features:
- Trigger playbook runs from different sources, including from CI systems such as Drone.
- Run multiple playbooks in parallel, all in separate processes
- Fast, friendly web interface with accompanying REST API
- Highly asynchronous, scalable back-end
- Full console log capture and storage
- Sends notifications of job status through HipChat
The above are its current Feature, We modified it a bit and gave a facility to add a simple trigger endpoint for the playbook and make it run on a click of a button.
Pre-requisites:
- Ansible 1.5+ – Follow the step here to install Ansible.
- Node.js 0.11.2+ – Installation instructions: http://nodejs.org/.
- MongoDB – Follow the step here to install MongoDB.
Setup Ansible Directory:
Place your Ansible playbooks somewhere, e.g. /playbooks.
Ansijet expects your playbooks folder to have a certain structure:
<playbooks folder>/*.yml <- your playbooks
<playbooks folder>/hosts <- Ansible hosts file
Ensure that any roles needed by your playbooks can be found by the ansible-playbook binary. An easy way to ensure this is to store your roles within the same folder, i.e. at <playbooks folder>/roles/. Same for group_vars and host_vars folders.
Setup Ansijet
$ git clone https://github.com/AjeetK/ansijet.git
$ cd ansijet
$ npm install -g gulp bower
$ npm install
$ bower install
$ npm run build
Now create ansijet/src/config/production.js:
"use strict";
module.exports = function(config) {
/** Path to folder containg Ansible playbooks */
config.playbooks = '/path/to/playbooks'
/** Max no. of jobs to execute in parallel. Should match no. of CPU cores. */
config.jobsInParallel = 1;
};
If you look inside ansijet/src/config/base.js you will see other configuration settings MongoDB, logging, etc. You may override these too within the config/production.js you created.
Run Ansijet
$ cd ansijet
$ NODE_ENV=production ./start-app.js
OR if it doesn’t work on ubuntu try the following command
$ cd ansijet
$ NODE_ENV=production /usr/bin/nodejs --harmony ./start-app.js
If you visit http://localhost:3000 you should see the dashboard showing the Active Jobs (there should be none currently).
Creating a Trigger
When you visit the URL http://localhost:3000 you will see the the home-page with all the playbook listed.
Click on any playbook for which you want to create a trigger. You will see the playbook and the a button to add a trigger.
After clicking on Add trigger button, you will see options to create a trigger. Give the trigger a Name, select the type (i.e. trigger to setup with Dron or Simple trigger to work on a click of a button). I have select “Simple” one.
Click on Next Step and than press Submit button. Now click on Deploy from Nav-bar and you will see a button for the trigger you have just created.
If you click on these button, say test-trigger-1, the corresponding playbook will get triggered and the logs will get stored in MongoDB. The logs can be seen from the Logs section in the nav-bar.
This is how you can use Ansijet to make it easy to run ansible-playbooks.