mirror of
				https://github.com/mmumshad/ansible-playable.git
				synced 2025-03-09 23:38:54 +00:00 
			
		
		
		
	Add option to disable adding custom ansible host engine
This commit is contained in:
		
							parent
							
								
									2fc2040882
								
							
						
					
					
						commit
						f06bd10330
					
				
					 9 changed files with 95 additions and 54 deletions
				
			
		| 
						 | 
				
			
			@ -63,6 +63,10 @@ The tool currently supports the following features and functionality:
 | 
			
		|||
  - Auto update documentation and parameter section based on user input
 | 
			
		||||
  - Provides default properties and available types in UI
 | 
			
		||||
  - Test developed custom module
 | 
			
		||||
- Admin
 | 
			
		||||
  - View list of users
 | 
			
		||||
  - Delete Users
 | 
			
		||||
  - View System and Server logs from the Admin tab
 | 
			
		||||
 | 
			
		||||
### Prerequisites
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,12 +7,15 @@ import routes from './project.routes';
 | 
			
		|||
 | 
			
		||||
export class ProjectComponent {
 | 
			
		||||
  /*@ngInject*/
 | 
			
		||||
  constructor($scope, Projects, Auth, appConfig) {
 | 
			
		||||
  constructor($scope, Projects, Auth, appConfig, system) {
 | 
			
		||||
    'ngInject';
 | 
			
		||||
    var default_project_folder = '/opt/ehc-ansible-projects/';
 | 
			
		||||
 | 
			
		||||
    var projectCtrl = this;
 | 
			
		||||
 | 
			
		||||
    system.getConfigDisableAnsibleHostAddition((response) => {
 | 
			
		||||
      projectCtrl.disableAnsibleHostAddition = response.data;
 | 
			
		||||
      console.log(projectCtrl.disableAnsibleHostAddition)
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    // Define a blank project object
 | 
			
		||||
    projectCtrl.blankProject = {
 | 
			
		||||
      name: '',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,11 @@
 | 
			
		|||
          <input type="text" ng-model="projectCtrl.newProject.name" class="form-control" ng-required="true">
 | 
			
		||||
        </p>
 | 
			
		||||
 | 
			
		||||
        <div class="alert alert-warning" ng-if="projectCtrl.disableAnsibleHostAddition == 'true'">
 | 
			
		||||
          Adding a custom Ansible Engine (Ansible Controller) is disabled in the demo mode.
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <div ng-if="projectCtrl.disableAnsibleHostAddition != 'true'">
 | 
			
		||||
          <p class="form-group">
 | 
			
		||||
            <label>Ansible Host</label>
 | 
			
		||||
            <input type="text" ng-model="projectCtrl.newProject.ansibleEngine.ansibleHost" class="form-control">
 | 
			
		||||
| 
						 | 
				
			
			@ -38,12 +43,14 @@
 | 
			
		|||
          <div ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost" class="hint">A directory path on the Ansible Host to store custom modules for this project </div>
 | 
			
		||||
          </p>
 | 
			
		||||
 | 
			
		||||
        </div>
 | 
			
		||||
 | 
			
		||||
        <button class="btn btn-success" ng-disabled="!projectCtrl.newProject.name" ng-click="projectCtrl.createProject()"> Save <span class="fa {{projectCtrl.saveButtonIcon}}"></span></button>
 | 
			
		||||
        <button class="btn btn-warning" ng-click="projectCtrl.hideProjectForm()"> Cancel <span class="fa fa-times"></span></button>
 | 
			
		||||
 | 
			
		||||
      </form>
 | 
			
		||||
 | 
			
		||||
      <div ng-if="msg" class="alert alert-{{ projectCtrl.msg_status }}">{{ projectCtrl.msg }}</div>
 | 
			
		||||
      <div ng-if="projectCtrl.msg" class="alert alert-{{ projectCtrl.msg_status }}">{{ projectCtrl.msg }}</div>
 | 
			
		||||
 | 
			
		||||
    </div>
 | 
			
		||||
  </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,9 +7,14 @@ export function systemService($http) {
 | 
			
		|||
 | 
			
		||||
  const api_system = '/api/system';
 | 
			
		||||
  const api_get_logs = api_system + '/logs';
 | 
			
		||||
  const get_config_disable_ansible_host_addition = api_system + '/config/disable_ansible_host_addition';
 | 
			
		||||
 | 
			
		||||
  this.getLogs = function(type, successCallback, errorCallback){
 | 
			
		||||
    $http.get(api_get_logs + '/' + type).then(successCallback, errorCallback);
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  this.getConfigDisableAnsibleHostAddition = function(successCallback, errorCallback){
 | 
			
		||||
    $http.get(get_config_disable_ansible_host_addition).then(successCallback, errorCallback);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -109,6 +109,10 @@ export function create(req, res) {
 | 
			
		|||
  req.body.owner_id = req.user._id;
 | 
			
		||||
  req.body.owner_name = req.user.name;
 | 
			
		||||
 | 
			
		||||
  if(config.disableAnsibleHostAddition == "true" && ansibleEngine.ansibleHost && ansibleEngine.ansibleHost !== 'localhost'){
 | 
			
		||||
    return res.status(500).send("Unable to add a custom Ansible Engine as ENV variable DISABLE_ANSIBLE_HOST_ADDITION is set to true")
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Set default values
 | 
			
		||||
  if(!ansibleEngine.ansibleHost){
 | 
			
		||||
    ansibleEngine = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,5 +7,6 @@ var router = express.Router();
 | 
			
		|||
 | 
			
		||||
router.get('/logs/server', controller.serverLogs);
 | 
			
		||||
router.get('/logs/api', controller.apiLogs);
 | 
			
		||||
router.get('/config/disable_ansible_host_addition', controller.getConfigDisableAnsibleHostAddition);
 | 
			
		||||
 | 
			
		||||
module.exports = router;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,3 +88,9 @@ exports.apiLogs = function(req,res){
 | 
			
		|||
  })
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.getConfigDisableAnsibleHostAddition = function(req,res){
 | 
			
		||||
 | 
			
		||||
  res.send(config.disableAnsibleHostAddition);
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -28,8 +28,12 @@ exports = module.exports = {
 | 
			
		|||
  },
 | 
			
		||||
 | 
			
		||||
  disablePlayboookExecution: process.env.DISABLE_PLAYBOOK_EXECUTION || false,
 | 
			
		||||
  // Disable adding a separate ansible host than localhost
 | 
			
		||||
  disableAnsibleHostAddition: process.env.DISABLE_ANSIBLE_HOST_ADDITION || false,
 | 
			
		||||
 | 
			
		||||
  videos: [
 | 
			
		||||
  videos
 | 
			
		||||
:
 | 
			
		||||
[
 | 
			
		||||
  {
 | 
			
		||||
    title: 'Overview',
 | 
			
		||||
    type: 'overview',
 | 
			
		||||
| 
						 | 
				
			
			@ -53,4 +57,5 @@ exports = module.exports = {
 | 
			
		|||
  }
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
}
 | 
			
		||||
;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,5 +24,11 @@ module.exports = {
 | 
			
		|||
 | 
			
		||||
  MONGODB_URI_DEV: 'mongodb://localhost/dev',
 | 
			
		||||
 | 
			
		||||
  DISABLE_PLAYBOOK_EXECUTION: true
 | 
			
		||||
  DISABLE_PLAYBOOK_EXECUTION: true,
 | 
			
		||||
  DISABLE_ANSIBLE_HOST_ADDITION: true,
 | 
			
		||||
 | 
			
		||||
  PASSWORD_TEST: 'test',
 | 
			
		||||
  PASSWORD_ADMIN: 'admin',
 | 
			
		||||
 | 
			
		||||
  SEED_DB: false
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue