-
Notifications
You must be signed in to change notification settings - Fork 0
/
03-import-components.yaml
75 lines (72 loc) · 3.64 KB
/
03-import-components.yaml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
- name: Import Components
hosts: localhost
vars_files:
- vars/common.yaml
- vars/organizations.yaml
vars:
tasks:
- name: Peer organizations import MSPs of other peer organizations
vars:
- org: "{{ peer_organizations[item[0]] }}"
- org_to_be_imported: "{{ peer_organizations[item[1]] }}"
ibm.blockchain_platform.external_organization:
state: "{{ state }}"
api_endpoint: "{{ org.console.api_endpoint }}"
api_authtype: "{{ org.console.api_authtype }}"
api_key: "{{ org.console.api_key | default(omit) }}"
api_secret: "{{ org.console.api_secret | default(omit)}}"
organization: "{{ lookup('file', '{{ components_path }}/{{ org_to_be_imported.msp.name }}_MSP.json') }}"
# debug:
# msg: "Item0: {{ org.msp.id }} --- Item1: {{ org_to_be_imported.msp.id }}"
with_nested:
- "{{ peer_organizations.keys() | list }}" #item[0]
- "{{ peer_organizations.keys() | list }}" #item[1]
- name: Peer organizations import MSPs of ordering organization(s)
vars:
- org: "{{ peer_organizations[item[0]] }}"
- org_to_be_imported: "{{ ordering_organization[item[1]] }}"
ibm.blockchain_platform.external_organization:
state: "{{ state }}"
api_endpoint: "{{ org.console.api_endpoint }}"
api_authtype: "{{ org.console.api_authtype }}"
api_key: "{{ org.console.api_key | default(omit) }}"
api_secret: "{{ org.console.api_secret | default(omit)}}"
organization: "{{ lookup('file', '{{ components_path }}/{{ org_to_be_imported.msp.name }}_MSP.json') }}"
with_nested:
- "{{ peer_organizations.keys() | list }}" #item[0]
- "{{ ordering_organization.keys() | list }}" #item[1]
- name: Ordering organization(s) import MSPs of other peer organizations
vars:
- org: "{{ ordering_organization[item[0]] }}"
- org_to_be_imported: "{{ peer_organizations[item[1]] }}"
ibm.blockchain_platform.external_organization:
state: "{{ state }}"
api_endpoint: "{{ org.console.api_endpoint }}"
api_authtype: "{{ org.console.api_authtype }}"
api_key: "{{ org.console.api_key | default(omit) }}"
api_secret: "{{ org.console.api_secret | default(omit)}}"
organization: "{{ lookup('file', '{{ components_path }}/{{ org_to_be_imported.msp.name }}_MSP.json') }}"
with_nested:
- "{{ ordering_organization.keys() | list }}" #item[0]
- "{{ peer_organizations.keys() | list }}" #item[1]
- name: Peer organizations import orderers of ordering organization(s)
vars:
- org: "{{ peer_organizations[item[0]] }}"
- org_to_be_imported: "{{ ordering_organization[item[1]] }}"
ibm.blockchain_platform.external_ordering_service:
state: "{{ state }}"
api_endpoint: "{{ org.console.api_endpoint }}"
api_authtype: "{{ org.console.api_authtype }}"
api_key: "{{ org.console.api_key | default(omit) }}"
api_secret: "{{ org.console.api_secret | default(omit)}}"
ordering_service: "{{ lookup('file', '{{ components_path }}/{{ org_to_be_imported.orderer.name }}_Orderer.json') }}"
register: result
failed_when:
- 'result.failed == true'
# If the ordering organization is hosted in the same IBP instance as one of the organizations,
# IBP will return error upon importing. Ignore the error if it consists of the error string
- '"exists and appears to be managed by this console" not in result.msg'
with_nested:
- "{{ peer_organizations.keys() | list }}" #item[0]
- "{{ ordering_organization.keys() | list }}" #item[1]