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

Commit 7f27c6b

Browse files
committed
Update Ansible configuration for deploying dashboard using runtime
environment variables
1 parent 1f51ae4 commit 7f27c6b

21 files changed

+66
-76
lines changed

.env

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Example Configuration
2+
elasticsearch='http://test_domain.com'
3+
results='http://test_domain.com'
4+
graphql='http://test_domain.com'
5+
prefix='test_prefix.'
6+
result_index='test_index.'
7+
run_index='test_index.'

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ package-lock.json
3131
__snapshots__
3232

3333
# config
34-
/config/endpoints.js
34+
.env

README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ This will automatically open the application on [http://localhost:8000](http://l
7070

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

73-
`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.
73+
`public/endpoints.js` contains references to datastores required to visualize data in the dashboard. Please reference the following example for required configuration fields:
7474

7575
```JavaScript
76-
export default {
77-
"elasticsearch": "http://elasticsearch.example.com",
78-
"results": "http://results.example.com",
79-
"graphql": "http://graphql.example.com",
80-
"prefix": "example.prefix",
81-
"run_index": "example.index",
82-
"result_index": "example.index"
83-
}
76+
window.endpoints = {
77+
elasticsearch: 'http://test_domain.com',
78+
results: 'http://test_domain.com',
79+
graphql: 'http://test_domain.com',
80+
prefix: 'test_prefix.',
81+
result_index: 'test_index.',
82+
run_index: 'test_index.'
83+
};
8484
```
8585

8686
## Storage Config

ansible/README.md

+19-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@ This will ease installation, and deployment of the pbench dashboard.
33

44
## Required
55
- Ansible needs to be installed on the host where you want to run this playbook
6-
- An inventory file containing the following key values defined:
7-
- "`elasticsearch_url`", "`results_url`", "`graphql_url`", "`run_index`", "`prefix`"
8-
See the `/README.md` for more details.
6+
- An inventory file containing the server values defined
7+
8+
## Endpoint Configuration
9+
API endpoints are defined in `public/endpoints.js` as runtime configuration variables for reference in the dashboard binary. Before deployment of the binary to a remote host, consider the configuration at `public/endpoints.js` as the file is copied to the target server during deployment. Please reference the following example for required configuration fields:
10+
11+
```JavaScript
12+
window.endpoints = {
13+
elasticsearch: 'http://test_domain.com',
14+
results: 'http://test_domain.com',
15+
graphql: 'http://test_domain.com',
16+
prefix: 'test_prefix.',
17+
result_index: 'test_index.',
18+
run_index: 'test_index.'
19+
};
20+
```
921

1022
## Run
1123
Running the below commands from this checked-out directory to install the
1224
pbench dashboard components locally, and then deploy hosts mentioned under
13-
the "`[servers:children]`" section of the given `inventory` file.
14-
15-
There's also an option to define the dashboard configuration in the provided
16-
inventory file.
25+
the "`[servers]`" section of the given `inventory` file.
1726

1827
See the `inventory` file in this directory for an example.
1928
```
29+
$ # First bundle the dashboard for production
30+
$ yarn build
31+
$
2032
$ # First add a link to the "dist" folder where the dashboard will be built.
2133
$ ln -sf ../dist dist
2234
$ ansible-playbook -i inventory dashboard-install.yml

ansible/config.json.j2

-1
This file was deleted.

ansible/inventory

+3-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
[servers:children]
2-
ui-server
3-
user-server
4-
5-
[servers:vars]
6-
results_url="http://{{ inventory_hostname }}"
7-
run_index="run.example"
8-
graphql_url="http://{{ inventory_hostname }}"
9-
10-
[ui-server]
11-
ui-server.example.com
12-
13-
[ui-server:vars]
14-
elasticsearch_url="http://elasticsearch.example.com"
15-
prefix="ui-server.example."
16-
17-
[user-server]
18-
user-server.example.com
19-
20-
[user-server:vars]
21-
elasticsearch_url="http://elasticsearch.example.com"
22-
prefix="user-server.example."
1+
[servers]
2+
staging-server.example.com
3+
production-server.example.com

ansible/roles/dashboard-deploy/tasks/main.yml

-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,3 @@
1313
dest: /var/www/html/dashboard
1414
owner: pbench
1515
group: pbench
16-
17-
- name: initialize dashboard config file
18-
template: src=config.json.j2 dest=/var/www/html/dashboard/config.json mode=0644 owner=pbench group=pbench

config.json.j2

-8
This file was deleted.

config/config.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import pageRoutes from './router.config';
2-
import endpoints from './endpoints';
32

43
export default {
5-
define: {
6-
'process.env.endpoints': endpoints,
7-
},
84
dynamicImport: undefined,
95
base: '/dashboard/',
106
publicPath: process.env.NODE_ENV === 'development' ? '/' : '/dashboard/',

config/endpoints.js

-8
This file was deleted.

mock/api.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
// eslint-disable-next-line import/no-unresolved
2-
import endpoints from '../config/endpoints';
31
import constants from '../config/constants';
42

3+
// Mocked test index components
4+
const endpoints = {
5+
prefix: 'test_prefix.',
6+
run_index: 'test_index.',
7+
};
8+
59
// Generate controllers as per max page size options
610
const maxTableSize = parseInt(constants.tableSizeOptions.pop(), 10);
711
let generatedBuckets = new Array(maxTableSize).fill({});

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "pbench_dashboard",
3-
"version": "2.2.0",
3+
"version": "2.2.1-0",
44
"description": "UI solution for scalable visualization of benchmark data.",
55
"private": true,
66
"scripts": {
77
"precommit": "npm run lint-staged",
8-
"start": "cross-env UMI_UI=none umi dev",
9-
"start:no-mock": "cross-env MOCK=none umi dev",
8+
"start": "cross-env UMI_UI=none MOCK=none umi dev",
109
"build": "npm --no-git-tag-version version prerelease && umi build",
1110
"site": "umi-api-doc static && gh-pages -d dist",
1211
"analyze": "cross-env ANALYZE=true umi build",

public/endpoints.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
window.endpoints = {
2+
elasticsearch: 'http://elasticsearch.perf.lab.eng.bos.redhat.com:9280',
3+
results: 'http://pbench.perf.lab.eng.bos.redhat.com',
4+
graphql: 'http://graphql.perf.lab.eng.bos.redhat.com:4466',
5+
run_index: 'run.',
6+
result_index: 'result-data.',
7+
prefix: 'dsa-pbench.v4.',
8+
};

src/models/datastore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default {
1111
effects: {
1212
*fetchMonthIndices({ payload }, { call, put }) {
1313
const response = yield call(queryMonthIndices, payload);
14-
const { endpoints } = process.env;
14+
const { endpoints } = window;
1515
const indices = [];
1616

1717
const prefix = endpoints.prefix + endpoints.run_index.slice(0, -1);

src/models/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
*fetchIndexMapping({ payload }, { call, put }) {
2121
const response = yield call(queryIndexMapping, payload);
2222
const { indices } = payload;
23-
const { endpoints } = process.env;
23+
const { endpoints } = window;
2424

2525
const index = endpoints.prefix + endpoints.run_index + indices[0];
2626
const mapping = response[index].mappings['pbench-run'].properties;

src/pages/document.ejs

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
<meta http-equiv="X-UA-Compatible" content="IE=edge">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<title>Pbench Dashboard</title>
9-
<link rel="icon" href="/favicon.ico" type="image/x-icon">
9+
<link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon">
10+
11+
<!-- runtime endpoints config -->
12+
<script src="<%= context.config.publicPath +'endpoints.js'%>"></script>
1013
</head>
1114

1215
<body>

src/services/dashboard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import request from '../utils/request';
55
import { getAllMonthsWithinRange } from '../utils/moment_constants';
66

7-
const { endpoints } = process.env;
7+
const { endpoints } = window;
88

99
function scrollUntilEmpty(data) {
1010
const endpoint = `${endpoints.elasticsearch}/_search/scroll?scroll=1m`;

src/services/datastore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import request from '../utils/request';
22

3-
const { endpoints } = process.env;
3+
const { endpoints } = window;
44

55
export default async function queryMonthIndices() {
66
const endpoint = `${endpoints.elasticsearch}/_aliases`;

src/services/explore.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import request from '../utils/request';
22

3-
const { endpoints } = process.env;
3+
const { endpoints } = window;
44

55
// queries all the available shared sessions from the database to display
66
export async function querySharedSessions() {

src/services/global.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import request from '../utils/request';
22

3-
const { endpoints } = process.env;
3+
const { endpoints } = window;
44

55
export async function saveUserSession(params) {
66
const { sessionConfig, description } = params;

src/services/search.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getAllMonthsWithinRange } from '../utils/moment_constants';
22
import request from '../utils/request';
33

4-
const { endpoints } = process.env;
4+
const { endpoints } = window;
55

66
export async function queryIndexMapping(params) {
77
const { indices } = params;

0 commit comments

Comments
 (0)