mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Implement disabling playbook execution based on environment variable
This commit is contained in:
parent
04a29ed2fe
commit
babc1c5e6c
5 changed files with 32 additions and 10 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
import jsonpatch from 'fast-json-patch';
|
||||
import Ansible from './ansible.model';
|
||||
import config from '../../config/environment';
|
||||
var ssh2_exec = require('../../components/ssh/ssh2_exec');
|
||||
var ansibleTool = require('../../components/ansible/ansible_tool');
|
||||
|
||||
|
@ -112,7 +113,6 @@ export function modules(req, res) {
|
|||
|
||||
// Gets a single Deploy from the DB
|
||||
export function getLogs(req, res) {
|
||||
console.log("Param ID " + req.params.id);
|
||||
return Ansible.findById(req.params.id).exec()
|
||||
.then(handleEntityNotFound(res))
|
||||
.then(function(entity){
|
||||
|
@ -130,12 +130,18 @@ export function getLogs(req, res) {
|
|||
.catch(handleError(res));
|
||||
}
|
||||
|
||||
console.log("config.disablePlayboookExecution =" + config.disablePlayboookExecution);
|
||||
|
||||
// Executes Ansible Play book in the backend
|
||||
export function execute(req, res) {
|
||||
|
||||
//var inventory_file_contents = req.body.inventory_file_contents;
|
||||
//var playbook_file_contents = req.body.playbook_file_contents;
|
||||
|
||||
if(config.disablePlayboookExecution){
|
||||
return res.status(500).send('Playbook execution has been disabled. Set environment variable DISABLE_PLAYBOOK_EXECUTION to "false" and restart web server')
|
||||
}
|
||||
|
||||
var playbook_name = req.body.selectedPlaybook;
|
||||
var inventory_file_name = req.body.inventory_file_name;
|
||||
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
|
||||
import jsonpatch from 'fast-json-patch';
|
||||
import CustomModule from './custom_module.model';
|
||||
var ssh2_exec = require('../../components/ssh/ssh2_exec');
|
||||
var scp2_exec = require('../../components/scp/scp_exec');
|
||||
import config from '../../config/environment';
|
||||
const ssh2_exec = require('../../components/ssh/ssh2_exec');
|
||||
const scp2_exec = require('../../components/scp/scp_exec');
|
||||
|
||||
const logger = require('../../components/logger/logger');
|
||||
|
||||
|
@ -134,6 +135,10 @@ export function testModule(req, res) {
|
|||
|
||||
var moduleArgs = req.body.moduleArgs;
|
||||
|
||||
if(config.disablePlayboookExecution){
|
||||
return res.status(500).send('Testing has been disabled. Set environment variable DISABLE_PLAYBOOK_EXECUTION to "false" and restart web server')
|
||||
}
|
||||
|
||||
if(!ansibleEngine.customModules){
|
||||
res.status(500).send("Custom Modules Folder not defined in Ansible Engine")
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var ssh2_exec = require('../ssh/ssh2_exec');
|
||||
var scp2_exec = require('../scp/scp_exec');
|
||||
var config = require('../../config/environment');
|
||||
const ssh2_exec = require('../ssh/ssh2_exec');
|
||||
const scp2_exec = require('../scp/scp_exec');
|
||||
const config = require('../../config/environment');
|
||||
const util = require('util');
|
||||
const Q = require("q");
|
||||
|
||||
|
@ -8,7 +8,7 @@ const all_commands = require('../../config/commands');
|
|||
|
||||
const logger = require('../logger/logger');
|
||||
|
||||
var local_logPath = 'logs/ansible/execute/';
|
||||
const local_logPath = 'logs/ansible/execute/';
|
||||
|
||||
/**
|
||||
* Get Logs
|
||||
|
@ -373,7 +373,7 @@ exports.deletePlaybook = function(project_folder,playbook_file_name, dataCallbac
|
|||
exports.getPlaybookList = function(project_folder, successCallback, errorCallback, ansibleEngine){
|
||||
|
||||
var playbook_file_path = project_folder + '/';
|
||||
var command = util.format(all_commands.general.get_playbook_list, playbook_file_path);
|
||||
var command = util.format(all_commands.ansible.get_playbook_list, playbook_file_path);
|
||||
var ansiblePlaybookListResults = "";
|
||||
|
||||
ssh2_exec.executeCommand(command,
|
||||
|
|
|
@ -25,5 +25,8 @@ exports = module.exports = {
|
|||
ansible_project_library: '/library', // relative to project folder
|
||||
ansible_project_roles: '/roles', // relative to project folder
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
disablePlayboookExecution: process.env.DISABLE_PLAYBOOK_EXECUTION || false
|
||||
|
||||
};
|
||||
|
|
|
@ -16,5 +16,13 @@ module.exports = {
|
|||
GOOGLE_SECRET: 'secret',
|
||||
|
||||
// Control debug level for modules using visionmedia/debug
|
||||
DEBUG: ''
|
||||
DEBUG: '',
|
||||
|
||||
SCRIPT_ENGINE_HOST : 'localhost',
|
||||
SCRIPT_ENGINE_USER : 'root',
|
||||
SCRIPT_ENGINE_PASSWORD : 'P@ssw0rd@123',
|
||||
|
||||
MONGODB_URI_DEV: 'mongodb://localhost/dev',
|
||||
|
||||
DISABLE_PLAYBOOK_EXECUTION: true
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue