mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Add support for custom modules
This commit is contained in:
parent
d287b8cb6d
commit
c8ac97657e
6 changed files with 354 additions and 22 deletions
|
@ -105,7 +105,13 @@ export function show(req, res) {
|
|||
var command = 'cat "' + ansibleEngine.customModules + '"/' + req.params.custom_module;
|
||||
|
||||
if(req.params.custom_module === 'template.py'){
|
||||
command = 'cat ' + '/opt/ehc-builder-scripts/ansible_modules/template.py';
|
||||
//command = 'cat ' + '/opt/ehc-builder-scripts/ansible_modules/template.py';
|
||||
|
||||
return require('fs').readFile('./helpers/module_template.py', (err, data) => {
|
||||
if (err) res.status(500).send(data);
|
||||
res.send(data);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,20 +143,27 @@ export function testModule(req, res) {
|
|||
res.status(500).send("Custom Modules Folder not defined in Ansible Engine")
|
||||
}
|
||||
|
||||
var command = '/opt/ansible/ansible-devel/hacking/test-module -m "' + ansibleEngine.customModules + '/' + req.params.custom_module + "\" -a '" + JSON.stringify(moduleArgs) + "'";
|
||||
var test_module = '/tmp/test-module';
|
||||
|
||||
console.log("Command=" + command);
|
||||
var command = 'chmod 755 ' + test_module + '; ' + test_module + ' -m "' + ansibleEngine.customModules + '/' + req.params.custom_module + "\" -a '" + JSON.stringify(moduleArgs) + "'";
|
||||
|
||||
scp2_exec.copyFileToScriptEngine('./helpers/test-module',test_module,ansibleEngine,function(){
|
||||
console.log("Command=" + command);
|
||||
|
||||
ssh2_exec.executeCommand(command,
|
||||
null,
|
||||
function(data){
|
||||
res.send(data);
|
||||
},
|
||||
function(data){
|
||||
res.status(500).send(data)
|
||||
},
|
||||
ansibleEngine
|
||||
);
|
||||
}, function(errorResponse){
|
||||
res.status(500).send(errorResponse)
|
||||
});
|
||||
|
||||
ssh2_exec.executeCommand(command,
|
||||
null,
|
||||
function(data){
|
||||
res.send(data);
|
||||
},
|
||||
function(data){
|
||||
res.status(500).send(data)
|
||||
},
|
||||
ansibleEngine
|
||||
);
|
||||
|
||||
/*return CustomModule.findById(req.params.custom_module).exec()
|
||||
.then(handleEntityNotFound(res))
|
||||
|
|
|
@ -36,26 +36,26 @@ describe('CustomModule API Router:', function() {
|
|||
expect(customModuleIndex).to.equal(routerStub);
|
||||
});
|
||||
|
||||
describe('GET /api/custom_modules', function() {
|
||||
describe('GET /api/custom_modules/query', function() {
|
||||
it('should route to customModule.controller.index', function() {
|
||||
expect(routerStub.get
|
||||
.withArgs('/', 'customModuleCtrl.index')
|
||||
expect(routerStub.post
|
||||
.withArgs('/query', 'customModuleCtrl.index')
|
||||
).to.have.been.calledOnce;
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /api/custom_modules/:id', function() {
|
||||
describe('GET /api/custom_modules/:custom_module/get', function() {
|
||||
it('should route to customModule.controller.show', function() {
|
||||
expect(routerStub.get
|
||||
.withArgs('/:id', 'customModuleCtrl.show')
|
||||
expect(routerStub.post
|
||||
.withArgs('/:custom_module/get', 'customModuleCtrl.show')
|
||||
).to.have.been.calledOnce;
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST /api/custom_modules', function() {
|
||||
describe('POST /api/custom_modules/:custom_module', function() {
|
||||
it('should route to customModule.controller.create', function() {
|
||||
expect(routerStub.post
|
||||
.withArgs('/', 'customModuleCtrl.create')
|
||||
.withArgs('/:custom_module', 'customModuleCtrl.create')
|
||||
).to.have.been.calledOnce;
|
||||
});
|
||||
});
|
||||
|
|
|
@ -11,6 +11,6 @@ module.exports = {
|
|||
},
|
||||
|
||||
// Seed database on startup
|
||||
seedDB: true
|
||||
seedDB: false
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue