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

Commit 595e8bf

Browse files
committed
Update Ansible configuration for deploying dashboard using environment
variables
1 parent 1f51ae4 commit 595e8bf

File tree

12 files changed

+60
-65
lines changed

12 files changed

+60
-65
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

+8-10
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,15 @@ 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+
`.env` contains references to datastores required to visualize data in the dashboard. Please reference the following example for required configuration fields:
7474

75-
```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-
}
75+
```
76+
elasticsearch='http://test_domain.com'
77+
results='http://test_domain.com'
78+
graphql='http://test_domain.com'
79+
prefix='test_prefix.'
80+
result_index='test_index.'
81+
run_index='test_index.'
8482
```
8583

8684
## Storage Config

ansible/README.md

+18-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,31 @@ 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 `.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:
10+
11+
```
12+
elasticsearch='http://test_domain.com'
13+
results='http://test_domain.com'
14+
graphql='http://test_domain.com'
15+
prefix='test_prefix.'
16+
result_index='test_index.'
17+
run_index='test_index.'
18+
}
19+
```
920

1021
## Run
1122
Running the below commands from this checked-out directory to install the
1223
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.
24+
the "`[servers]`" section of the given `inventory` file.
1725

1826
See the `inventory` file in this directory for an example.
1927
```
28+
$ # First bundle the dashboard for production
29+
$ yarn build
30+
$
2031
$ # First add a link to the "dist" folder where the dashboard will be built.
2132
$ ln -sf ../dist dist
2233
$ 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

+8-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
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
16+
17+
- name: move .env to remote hosts
18+
copy:
19+
src: .env
20+
dest: /var/www/html/dashboard
21+
owner: pbench
22+
group: pbench
23+

config.json.j2

-8
This file was deleted.

config/config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import pageRoutes from './router.config';
2-
import endpoints from './endpoints';
2+
3+
require('dotenv').config();
34

45
export default {
56
define: {
6-
'process.env.endpoints': endpoints,
7+
'process.env.endpoints': process.env,
78
},
89
dynamicImport: undefined,
910
base: '/dashboard/',

config/endpoints.js

-8
This file was deleted.

mock/api.js

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

3+
// Mocked test endpoints
4+
const endpoints = {
5+
elasticsearch: 'http://test_domain.com',
6+
results: 'http://test_domain.com',
7+
graphql: 'http://test_domain.com',
8+
prefix: 'test_prefix.',
9+
result_index: 'test_index.',
10+
run_index: 'test_index.',
11+
};
12+
513
// Generate controllers as per max page size options
614
const maxTableSize = parseInt(constants.tableSizeOptions.pop(), 10);
715
let generatedBuckets = new Array(maxTableSize).fill({});

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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": {
@@ -36,6 +36,7 @@
3636
"ant-design-pro": "^2.1.1",
3737
"antd": "^3.16.1",
3838
"classnames": "^2.2.5",
39+
"dotenv": "^8.2.0",
3940
"dva": "^2.4.1",
4041
"dva-core": "^1.1.0",
4142
"enzyme-adapter-react-16": "^1.15.1",

0 commit comments

Comments
 (0)