Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
Update Ansible configuration for deploying dashboard using environment
Browse files Browse the repository at this point in the history
variables
  • Loading branch information
gurbirkalsi committed Dec 9, 2020
1 parent 1f51ae4 commit 2bb2418
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 63 deletions.
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Example Configuration
elasticsearch='http://test_domain.com'
results='http://test_domain.com'
graphql='http://test_domain.com'
prefix='test_prefix.'
result_index='test_index.'
run_index='test_index.'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ package-lock.json
__snapshots__

# config
/config/endpoints.js
.env
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,15 @@ This will automatically open the application on [http://localhost:8000](http://l

Both the production and development builds of the dashboard require API endpoint configurations in order to query data from specific datastores.

`endpoints.js` in the `config/` directory contains references to datastores required to visualize data in the dashboard. Please reference the following example for required configuration fields.
`.env` contains references to datastores required to visualize data in the dashboard. Please reference the following example for required configuration fields:

```JavaScript
export default {
"elasticsearch": "http://elasticsearch.example.com",
"results": "http://results.example.com",
"graphql": "http://graphql.example.com",
"prefix": "example.prefix",
"run_index": "example.index",
"result_index": "example.index"
}
```
elasticsearch='http://test_domain.com'
results='http://test_domain.com'
graphql='http://test_domain.com'
prefix='test_prefix.'
result_index='test_index.'
run_index='test_index.'
```

## Storage Config
Expand Down
25 changes: 18 additions & 7 deletions ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,31 @@ This will ease installation, and deployment of the pbench dashboard.

## Required
- Ansible needs to be installed on the host where you want to run this playbook
- An inventory file containing the following key values defined:
- "`elasticsearch_url`", "`results_url`", "`graphql_url`", "`run_index`", "`prefix`"
See the `/README.md` for more details.
- An inventory file containing the server values defined

## Endpoint Configuration
API endpoints are defined in `.env` as environment variables for reference in the dashboard binary. Before deployment of the binary to a remote host, consider the configuration at `.env` as the file is copied to the target server during deployment. Please reference the following example for required configuration fields:

```
elasticsearch='http://test_domain.com'
results='http://test_domain.com'
graphql='http://test_domain.com'
prefix='test_prefix.'
result_index='test_index.'
run_index='test_index.'
}
```

## Run
Running the below commands from this checked-out directory to install the
pbench dashboard components locally, and then deploy hosts mentioned under
the "`[servers:children]`" section of the given `inventory` file.

There's also an option to define the dashboard configuration in the provided
inventory file.
the "`[servers]`" section of the given `inventory` file.

See the `inventory` file in this directory for an example.
```
$ # First bundle the dashboard for production
$ yarn build
$
$ # First add a link to the "dist" folder where the dashboard will be built.
$ ln -sf ../dist dist
$ ansible-playbook -i inventory dashboard-install.yml
Expand Down
1 change: 0 additions & 1 deletion ansible/config.json.j2

This file was deleted.

25 changes: 3 additions & 22 deletions ansible/inventory
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
[servers:children]
ui-server
user-server

[servers:vars]
results_url="http://{{ inventory_hostname }}"
run_index="run.example"
graphql_url="http://{{ inventory_hostname }}"

[ui-server]
ui-server.example.com

[ui-server:vars]
elasticsearch_url="http://elasticsearch.example.com"
prefix="ui-server.example."

[user-server]
user-server.example.com

[user-server:vars]
elasticsearch_url="http://elasticsearch.example.com"
prefix="user-server.example."
[servers]
staging-server.example.com
production-server.example.com
11 changes: 8 additions & 3 deletions ansible/roles/dashboard-deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
dest: /var/www/html/dashboard
owner: pbench
group: pbench

- name: initialize dashboard config file
template: src=config.json.j2 dest=/var/www/html/dashboard/config.json mode=0644 owner=pbench group=pbench

- name: move .env to remote hosts
copy:
src: .env
dest: /var/www/html/dashboard
owner: pbench
group: pbench

8 changes: 0 additions & 8 deletions config.json.j2

This file was deleted.

5 changes: 3 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pageRoutes from './router.config';
import endpoints from './endpoints';

require('dotenv').config();

export default {
define: {
'process.env.endpoints': endpoints,
'process.env.endpoints': process.env,
},
dynamicImport: undefined,
base: '/dashboard/',
Expand Down
8 changes: 0 additions & 8 deletions config/endpoints.js

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pbench_dashboard",
"version": "2.2.0",
"version": "2.2.1-0",
"description": "UI solution for scalable visualization of benchmark data.",
"private": true,
"scripts": {
Expand Down Expand Up @@ -36,6 +36,7 @@
"ant-design-pro": "^2.1.1",
"antd": "^3.16.1",
"classnames": "^2.2.5",
"dotenv": "^8.2.0",
"dva": "^2.4.1",
"dva-core": "^1.1.0",
"enzyme-adapter-react-16": "^1.15.1",
Expand Down

0 comments on commit 2bb2418

Please sign in to comment.