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
 | 
					  - Auto update documentation and parameter section based on user input
 | 
				
			||||||
  - Provides default properties and available types in UI
 | 
					  - Provides default properties and available types in UI
 | 
				
			||||||
  - Test developed custom module
 | 
					  - Test developed custom module
 | 
				
			||||||
 | 
					- Admin
 | 
				
			||||||
 | 
					  - View list of users
 | 
				
			||||||
 | 
					  - Delete Users
 | 
				
			||||||
 | 
					  - View System and Server logs from the Admin tab
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Prerequisites
 | 
					### Prerequisites
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,12 +7,15 @@ import routes from './project.routes';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class ProjectComponent {
 | 
					export class ProjectComponent {
 | 
				
			||||||
  /*@ngInject*/
 | 
					  /*@ngInject*/
 | 
				
			||||||
  constructor($scope, Projects, Auth, appConfig) {
 | 
					  constructor($scope, Projects, Auth, appConfig, system) {
 | 
				
			||||||
    'ngInject';
 | 
					    'ngInject';
 | 
				
			||||||
    var default_project_folder = '/opt/ehc-ansible-projects/';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    var projectCtrl = this;
 | 
					    var projectCtrl = this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    system.getConfigDisableAnsibleHostAddition((response) => {
 | 
				
			||||||
 | 
					      projectCtrl.disableAnsibleHostAddition = response.data;
 | 
				
			||||||
 | 
					      console.log(projectCtrl.disableAnsibleHostAddition)
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Define a blank project object
 | 
					    // Define a blank project object
 | 
				
			||||||
    projectCtrl.blankProject = {
 | 
					    projectCtrl.blankProject = {
 | 
				
			||||||
      name: '',
 | 
					      name: '',
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,40 +10,47 @@
 | 
				
			||||||
          <input type="text" ng-model="projectCtrl.newProject.name" class="form-control" ng-required="true">
 | 
					          <input type="text" ng-model="projectCtrl.newProject.name" class="form-control" ng-required="true">
 | 
				
			||||||
        </p>
 | 
					        </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <p class="form-group">
 | 
					        <div class="alert alert-warning" ng-if="projectCtrl.disableAnsibleHostAddition == 'true'">
 | 
				
			||||||
          <label>Ansible Host</label>
 | 
					          Adding a custom Ansible Engine (Ansible Controller) is disabled in the demo mode.
 | 
				
			||||||
          <input type="text" ng-model="projectCtrl.newProject.ansibleEngine.ansibleHost" class="form-control">
 | 
					        </div>
 | 
				
			||||||
        <div class="hint">Ansible Controller system - A linux system with Ansible Installed on it. Required if you want to execute Ansible playbooks. You could skip this and still generate playbooks but not test them.</div>
 | 
					 | 
				
			||||||
        </p>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
					        <div ng-if="projectCtrl.disableAnsibleHostAddition != 'true'">
 | 
				
			||||||
          <label>User</label>
 | 
					          <p class="form-group">
 | 
				
			||||||
          <input type="text" ng-model="projectCtrl.newProject.ansibleEngine.ansibleHostUser" class="form-control">
 | 
					            <label>Ansible Host</label>
 | 
				
			||||||
        </p>
 | 
					            <input type="text" ng-model="projectCtrl.newProject.ansibleEngine.ansibleHost" class="form-control">
 | 
				
			||||||
 | 
					          <div class="hint">Ansible Controller system - A linux system with Ansible Installed on it. Required if you want to execute Ansible playbooks. You could skip this and still generate playbooks but not test them.</div>
 | 
				
			||||||
 | 
					          </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
					          <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
				
			||||||
          <label>Host Password</label>
 | 
					            <label>User</label>
 | 
				
			||||||
          <input type="password" ng-model="projectCtrl.newProject.ansibleEngine.ansibleHostPassword" class="form-control">
 | 
					            <input type="text" ng-model="projectCtrl.newProject.ansibleEngine.ansibleHostUser" class="form-control">
 | 
				
			||||||
        </p>
 | 
					          </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
					          <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
				
			||||||
          <label>Project Folder</label>
 | 
					            <label>Host Password</label>
 | 
				
			||||||
          <input ng-readonly="projectCtrl.editProjectFlag" ng-model="projectCtrl.newProject.ansibleEngine.projectFolder" class="form-control">
 | 
					            <input type="password" ng-model="projectCtrl.newProject.ansibleEngine.ansibleHostPassword" class="form-control">
 | 
				
			||||||
 | 
					          </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
				
			||||||
 | 
					            <label>Project Folder</label>
 | 
				
			||||||
 | 
					            <input ng-readonly="projectCtrl.editProjectFlag" ng-model="projectCtrl.newProject.ansibleEngine.projectFolder" class="form-control">
 | 
				
			||||||
          <div ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost" class="hint">A directory path on the Ansible Host to store files of this project </div>
 | 
					          <div ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost" class="hint">A directory path on the Ansible Host to store files of this project </div>
 | 
				
			||||||
        </p>
 | 
					          </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
					          <p class="form-group" ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost">
 | 
				
			||||||
          <label>Custom Modules Location</label>
 | 
					            <label>Custom Modules Location</label>
 | 
				
			||||||
          <input ng-readonly="projectCtrl.editProjectFlag" ng-model="projectCtrl.newProject.ansibleEngine.customModules" class="form-control">
 | 
					            <input ng-readonly="projectCtrl.editProjectFlag" ng-model="projectCtrl.newProject.ansibleEngine.customModules" class="form-control">
 | 
				
			||||||
          <div ng-if="projectCtrl.newProject.ansibleEngine.ansibleHost" class="hint">A directory path on the Ansible Host to store custom modules for this project </div>
 | 
					          <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>
 | 
					          </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-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>
 | 
					        <button class="btn btn-warning" ng-click="projectCtrl.hideProjectForm()"> Cancel <span class="fa fa-times"></span></button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      </form>
 | 
					      </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>
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,9 +7,14 @@ export function systemService($http) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const api_system = '/api/system';
 | 
					  const api_system = '/api/system';
 | 
				
			||||||
  const api_get_logs = api_system + '/logs';
 | 
					  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){
 | 
					  this.getLogs = function(type, successCallback, errorCallback){
 | 
				
			||||||
    $http.get(api_get_logs + '/' + type).then(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_id = req.user._id;
 | 
				
			||||||
  req.body.owner_name = req.user.name;
 | 
					  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
 | 
					  // Set default values
 | 
				
			||||||
  if(!ansibleEngine.ansibleHost){
 | 
					  if(!ansibleEngine.ansibleHost){
 | 
				
			||||||
    ansibleEngine = {
 | 
					    ansibleEngine = {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,5 +7,6 @@ var router = express.Router();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
router.get('/logs/server', controller.serverLogs);
 | 
					router.get('/logs/server', controller.serverLogs);
 | 
				
			||||||
router.get('/logs/api', controller.apiLogs);
 | 
					router.get('/logs/api', controller.apiLogs);
 | 
				
			||||||
 | 
					router.get('/config/disable_ansible_host_addition', controller.getConfigDisableAnsibleHostAddition);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = router;
 | 
					module.exports = router;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -88,3 +88,9 @@ exports.apiLogs = function(req,res){
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.getConfigDisableAnsibleHostAddition = function(req,res){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  res.send(config.disableAnsibleHostAddition);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,11 +4,11 @@ exports = module.exports = {
 | 
				
			||||||
  version: 'Alpha',
 | 
					  version: 'Alpha',
 | 
				
			||||||
  // List of user roles
 | 
					  // List of user roles
 | 
				
			||||||
  userRoles: ['guest', 'user', 'admin'],
 | 
					  userRoles: ['guest', 'user', 'admin'],
 | 
				
			||||||
  'scriptEngine' : {
 | 
					  'scriptEngine': {
 | 
				
			||||||
    'host' : process.env.SCRIPT_ENGINE_HOST || 'localhost',
 | 
					    'host': process.env.SCRIPT_ENGINE_HOST || 'localhost',
 | 
				
			||||||
    'user' : process.env.SCRIPT_ENGINE_USER || 'root',
 | 
					    'user': process.env.SCRIPT_ENGINE_USER || 'root',
 | 
				
			||||||
    // This is the default root password for local container set during docker container rebuild
 | 
					    // This is the default root password for local container set during docker container rebuild
 | 
				
			||||||
    'password' : process.env.SCRIPT_ENGINE_PASSWORD || 'P@ssw0rd@123'
 | 
					    'password': process.env.SCRIPT_ENGINE_PASSWORD || 'P@ssw0rd@123'
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  paths: {
 | 
					  paths: {
 | 
				
			||||||
| 
						 | 
					@ -28,29 +28,34 @@ exports = module.exports = {
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  disablePlayboookExecution: process.env.DISABLE_PLAYBOOK_EXECUTION || false,
 | 
					  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',
 | 
					  {
 | 
				
			||||||
      video_id: '6sE0Gqcw_4U'
 | 
					    title: 'Overview',
 | 
				
			||||||
    },
 | 
					    type: 'overview',
 | 
				
			||||||
    {
 | 
					    video_id: '6sE0Gqcw_4U'
 | 
				
			||||||
      title: 'Getting Started',
 | 
					  },
 | 
				
			||||||
      type: 'getting_started'
 | 
					  {
 | 
				
			||||||
    },
 | 
					    title: 'Getting Started',
 | 
				
			||||||
    {
 | 
					    type: 'getting_started'
 | 
				
			||||||
      title: 'Google Cloud Example',
 | 
					  },
 | 
				
			||||||
      type: 'google_cloud'
 | 
					  {
 | 
				
			||||||
    },
 | 
					    title: 'Google Cloud Example',
 | 
				
			||||||
    {
 | 
					    type: 'google_cloud'
 | 
				
			||||||
      title: 'VMWare Example',
 | 
					  },
 | 
				
			||||||
      type: 'vmware'
 | 
					  {
 | 
				
			||||||
    },
 | 
					    title: 'VMWare Example',
 | 
				
			||||||
    {
 | 
					    type: 'vmware'
 | 
				
			||||||
      title: 'Custom Modules',
 | 
					  },
 | 
				
			||||||
      type: 'custom_module'
 | 
					  {
 | 
				
			||||||
    }
 | 
					    title: 'Custom Modules',
 | 
				
			||||||
  ]
 | 
					    type: 'custom_module'
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
};
 | 
					}
 | 
				
			||||||
 | 
					;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -24,5 +24,11 @@ module.exports = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  MONGODB_URI_DEV: 'mongodb://localhost/dev',
 | 
					  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