-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.yml
57 lines (45 loc) · 2.97 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
- hosts: localhost
connection: local
vars:
project_name: "myproject"
username: "system:admin"
password: "lala"
master_url: "https://127.0.0.1:8443/"
tasks:
- name: login as {{ username }} (must be cluster-admin)
shell: "oc login -u system:admin"
#shell: "oc login -u {{ username }} -p {{ password }} {{ master_url }}"
#shell: oc login https://127.0.0.1:8443 --token=FwgcAV8Wz0TPuLIQYzNY9kKvLSoMS5MUvA0UzVXFl9s
- name: Add permissions
shell: "oc adm policy add-scc-to-user {{ item }} -z default -n {{ project_name }}"
with_items:
- anyuid
- privileged
- name: Deploy Hyperledger Explorer Database
shell: "oc apply -f kubernetes/blockchain-explorer-db_deploy.yaml -n {{ project_name }}"
- name: Create Explorer Service
shell: "oc apply -f kubernetes/blockchain-explorer-db_svc.yaml -n {{ project_name }}"
- name: Wait for postgresql to be ready
shell: oc get po -n "{{ project_name }}" | grep -i blockchain-explorer-db
register: postgresql_explorer
until: postgresql_explorer.stdout.find("Running") != -1
retries: 60
delay: 40
- name: Populate database
shell: |
pod=$(oc get pods | grep blockchain-explorer-db | awk '{print $1}')
oc -n "{{ project_name }}" exec $pod -- bash -c 'mkdir -p /fabric/config/explorer/db/ && mkdir -p /fabric/config/explorer/app/ && cd /fabric/config/explorer/db/ && wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/createdb.sh -O createdb.sh && wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/explorerpg.sql -O explorerpg.sql && wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/processenv.js -O processenv.js && wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/updatepg.sql -O updatepg.sql && apk update && apk add jq ; apk add nodejs ; apk add sudo ; rm -rf /var/cache/apk/* && chmod +x ./createdb.sh && ./createdb.sh'
#wget https://raw.githubusercontent.com/hyperledger/blockchain-explorer/master/app/persistence/fabric/postgreSQL/db/createdb.sh -O createdb.sh &&
- name: Copy network file
shell: oc -n "{{ project_name }}" cp config/explorer/app/config.json fabric-tools:/fabric/config/explorer/app/
ignore_errors: true
- name: Copy run.sh
shell: chmod +x config/explorer/app/run.sh && oc -n "{{ project_name }}" cp config/explorer/app/run.sh fabric-tools:/fabric/config/explorer/app/
ignore_errors: true
- name: Deploy explorer
shell: "oc apply -f kubernetes/blockchain-explorer-app_deploy.yaml -n {{ project_name }}"
- name: Create explorer svc
shell: "oc expose deployment blockchain-explorer-app --port=8080 -n {{ project_name }} || echo 'ja existe'"
- name: Create explorer route
shell: "oc expose svc/blockchain-explorer-app -n {{ project_name }} || echo 'ja existe'"