mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
Provide additional parameters to seed default user accounts
Update Readme file
This commit is contained in:
parent
f06bd10330
commit
de41ae22e8
3 changed files with 85 additions and 6 deletions
57
README.md
57
README.md
|
@ -25,7 +25,7 @@ Try a publicly hosted live demo at [ansible-playable.com](http://www.ansible-pla
|
|||
The easiest way to get started is to use Docker. The latest version of the software is built using docker and is available at [Docker hub](https://hub.docker.com/r/mmumshad/ansible-playable/)
|
||||
|
||||
Run the image to get started
|
||||
```angular2html
|
||||
```
|
||||
docker run -p 80:8080 mmumshad/ansible-playable
|
||||
```
|
||||
|
||||
|
@ -33,6 +33,17 @@ Remember to use port mapping to map http port to external host.
|
|||
|
||||
Once the docker container is running visit http://<docker host\> to access the web portal.
|
||||
|
||||
The above command should only be used for testing purpose as the changes you make are not saved. The projects you create are not retained after restarting docker container.
|
||||
|
||||
To persist data across docker container restarts use the below command to map volumes from docker container on the docker host.
|
||||
```
|
||||
docker run -p 80:8080 -v /data:/data -v /opt/ansible-projects:/opt/ansible-projects mmumshad/ansible-playable
|
||||
```
|
||||
|
||||
This command creates two volume maps - /data and /opt/ansible-projects. These directories must pre-exist on the docker host. All changes made by the docker container will now be stored in these folders.
|
||||
|
||||
Checkout Advanced Topics below for more details
|
||||
|
||||
## Features
|
||||
The tool currently supports the following features and functionality:
|
||||
- Ansible Engine
|
||||
|
@ -68,6 +79,50 @@ The tool currently supports the following features and functionality:
|
|||
- Delete Users
|
||||
- View System and Server logs from the Admin tab
|
||||
|
||||
### Advanced options
|
||||
|
||||
Some advanced options on customizing execution are given below
|
||||
|
||||
#### External database
|
||||
By default the web application uses a local mongodb instance. To use an external instance of MongoDB provide a different environmental variable using the -e parameter in docker command
|
||||
|
||||
```
|
||||
docker run -p 80:8080 -e MONGODB_URI=mongodb://dbuser:password@test.mlab.com/ansible-playable mmumshad/ansible-playable
|
||||
```
|
||||
|
||||
#### S3 storage for projects data
|
||||
By default all ansible projects and files are stored at location /opt/ansible-projects. You may map volume using docker run parameter -v to map a local volume on host to this directory.
|
||||
In case you need this to be on an external S3 store, set the below environment variables:
|
||||
|
||||
- AWS_ACCESS_KEY_ID=KEY
|
||||
- AWS_SECRET_ACCESS_KEY=SECRET_KEY
|
||||
- MOUNT_S3=True
|
||||
- S3_PATH=ansible-playable-storage/data
|
||||
|
||||
Example Command:
|
||||
```
|
||||
docker run -p 80:8080 -e AWS_ACCESS_KEY_ID=KEY -e - AWS_SECRET_ACCESS_KEY=SECRET_KEY -e MOUNT_S3=True -e S3_PATH=ansible-playable-storage/data mmumshad/ansible-playable
|
||||
```
|
||||
|
||||
#### Authentication
|
||||
|
||||
To configure Google Authentication provide the below keys:
|
||||
|
||||
- DOMAIN=http://ansible-playable.com
|
||||
- GOOGLE_ID=ID
|
||||
- GOOGLE_SECRET=SECRET
|
||||
|
||||
> Note: you must first configure google authentication and gather the GOOGLE_ID and GOOGLE_SECRET for this.
|
||||
|
||||
#### Admin user account
|
||||
By default the local admin account is created and the email used is "admin@example.com" and the password is "admin". Provide the below environment variables to use a different password or to recreate admin and test account
|
||||
|
||||
- SEED_DB=true
|
||||
- EMAIL_USER_ADMIN=admin@playable.com
|
||||
- PASSWORD_ADMIN=ADMIN_PASSWORD
|
||||
- EMAIL_USER_TEST=test@playable.com
|
||||
- PASSWORD_TEST=TEST_ACCOUNT_PASSWORD
|
||||
|
||||
### Prerequisites
|
||||
|
||||
#### With Docker
|
||||
|
|
|
@ -27,7 +27,9 @@ module.exports = {
|
|||
DISABLE_PLAYBOOK_EXECUTION: true,
|
||||
DISABLE_ANSIBLE_HOST_ADDITION: true,
|
||||
|
||||
EMAIL_USER_TEST: 'test@playable.com',
|
||||
PASSWORD_TEST: 'test',
|
||||
EMAIL_USER_ADMIN: 'admin@playable.com',
|
||||
PASSWORD_ADMIN: 'admin',
|
||||
|
||||
SEED_DB: false
|
||||
|
|
|
@ -6,25 +6,47 @@
|
|||
'use strict';
|
||||
import User from '../api/user/user.model';
|
||||
import config from './environment/';
|
||||
import logger from '../components/logger/logger';
|
||||
|
||||
export default function seedDatabaseIfNeeded() {
|
||||
if(config.seedDB) {
|
||||
logger.info('seedDB = %s', config.seedDB);
|
||||
if(config.seedDB == "true") {
|
||||
logger.info('Removing and re-creating local users');
|
||||
User.find({}).remove()
|
||||
.then(() => {
|
||||
User.create({
|
||||
provider: 'local',
|
||||
name: 'Test User',
|
||||
email: 'test@playable.com',
|
||||
email: process.env.EMAIL_USER_TEST || 'test@example.com',
|
||||
password: process.env.PASSWORD_TEST || 'test'
|
||||
}, {
|
||||
provider: 'local',
|
||||
role: 'admin',
|
||||
name: 'Admin',
|
||||
email: 'admin@playable.com',
|
||||
email: process.env.EMAIL_USER_ADMIN || 'admin@example.com',
|
||||
password: process.env.PASSWORD_ADMIN || 'admin'
|
||||
})
|
||||
.then(() => console.log('finished populating users'))
|
||||
.catch(err => console.log('error populating users', err));
|
||||
.then(() => logger.info('finished populating users'))
|
||||
.catch(err => logger.error('error populating users - %s', err));
|
||||
});
|
||||
}else{
|
||||
logger.info('Finding local admin user');
|
||||
User.find({name: 'Admin'}).then((user) => {
|
||||
if(!user){
|
||||
logger.info('Admin user not found, creating local admin user');
|
||||
User.create({
|
||||
provider: 'local',
|
||||
role: 'admin',
|
||||
name: 'Admin',
|
||||
email: process.env.EMAIL_USER_ADMIN || 'admin@example.com',
|
||||
password: process.env.PASSWORD_ADMIN || 'admin'
|
||||
})
|
||||
.then(() => logger.info('finished populating users'))
|
||||
.catch(err => logger.error('error populating users - %s', err));
|
||||
}else{
|
||||
logger.info('Admin user already exists.');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue