-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-create-ordering-org.yaml
230 lines (215 loc) · 9.93 KB
/
01-create-ordering-org.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
---
- name: Create Ordering Service Organization
hosts: localhost
vars_files:
- vars/common.yaml
- vars/organizations.yaml
vars:
# org_name: os
org: "{{ vars['ordering_organization'][org_name] }}"
enrollment_info: "{{ org.ca.id_list | selectattr('name','equalto', org.orderer.name) | first }}"
msp_admin_info: "{{ org.ca.id_list | selectattr('name', 'equalto', org.msp.admin) | list }}"
tasks:
- name: Create certificate authority
ibm.blockchain_platform.certificate_authority:
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)}}"
name: "{{ org.ca.name }}"
zone: "{{ org.ca.zone | default(omit) }}"
version: "{{ org.ca.version | default('1.4.7-1')}}"
config_override:
ca:
registry:
maxenrollments: -1
identities:
- name: "{{ org.ca.admin_enrollment_id }}"
pass: "{{ org.ca.admin_enrollment_secret }}"
type: client
maxenrollments: -1
attrs:
hf.Registrar.Roles: "*"
hf.Registrar.DelegateRoles: "*"
hf.Revoker: true
hf.IntermediateCA: true
hf.GenCRL: true
hf.Registrar.Attributes: "*"
hf.AffiliationMgr: true
resources:
ca:
requests:
cpu: "{{ org.ca.resource.vcpu | default('100m') }}"
memory: "{{ org.ca.resource.memory | default('200M') }}"
storage:
ca:
size: "{{ org.ca.resource.storage | default('20Gi') }}"
wait_timeout: "{{ wait_timeout | default(900) }}"
- name: Enroll CA admin
ibm.blockchain_platform.enrolled_identity:
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)}}"
certificate_authority: "{{ org.ca.name }}"
name: "{{ org.ca.admin_name }}"
enrollment_id: "{{ org.ca.admin_enrollment_id }}"
enrollment_secret: "{{ org.ca.admin_enrollment_secret }}"
path: "{{ wallet_path }}/{{ org.ca.admin_name }}.json"
- name: Register org admin, orderer and monitoring user
ibm.blockchain_platform.registered_identity:
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)}}"
certificate_authority: "{{ org.ca.name }}"
registrar: "{{ wallet_path }}/{{ org.ca.admin_name }}.json"
enrollment_id: "{{ item.enrollment_id }}"
enrollment_secret: "{{ item.enrollment_secret }}"
type: "{{ item.type }}"
loop: "{{ org.ca.id_list }}"
- name: Enroll the org admin
ibm.blockchain_platform.enrolled_identity:
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)}}"
certificate_authority: "{{ org.ca.name }}"
name: "{{ org.msp.admin }}"
enrollment_id: "{{ msp_admin_info[0].enrollment_id }}"
enrollment_secret: "{{ msp_admin_info[0].enrollment_secret }}"
path: "{{ wallet_path }}/{{ org.msp.admin }}.json"
register: org_admin
- name: Create organization
ibm.blockchain_platform.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)}}"
name: "{{ org.msp.name }}"
msp_id: "{{ org.msp.id }}"
certificate_authority: "{{ org.ca.name }}"
registrar: "{{ wallet_path }}/{{ org.ca.admin_name }}.json"
admins:
- "{{ org_admin.enrolled_identity.cert }}"
- name: Create ordering service
ibm.blockchain_platform.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) }}"
name: "{{ org.orderer.name }}"
msp_id: "{{ org.msp.id }}"
nodes: "{{ org.orderer.nodes }}"
zones: "{{ org.orderer.zones | default(omit) }}"
version: "{{ org.orderer.version | default('1.4.7-1')}}"
certificate_authority: "{{ org.ca.name }}"
enrollment_id: "{{ enrollment_info.enrollment_id }}"
enrollment_secret: "{{ enrollment_info.enrollment_secret }}"
admin_certificates:
- "{{ org_admin.enrolled_identity.cert }}"
resources:
orderer:
requests:
cpu: "{{ org.orderer.resource.orderer.vcpu | default('350m') }}"
memory: "{{ org.orderer.resource.orderer.memory | default('400M') }}"
proxy:
requests:
cpu: "{{ org.orderer.resource.proxy.vcpu | default('100m') }}"
memory: "{{ org.orderer.resource.proxy.memory | default('200M') }}"
storage:
orderer:
size: "{{ org.orderer.resource.orderer.storage | default('100Gi') }}"
wait_timeout: "{{ wait_timeout | default(900) }}"
register: result
until: result.msg is not defined or 'Failed' not in result.msg
retries: 3
delay: 5
- name: Retrieve the ordering service
ibm.blockchain_platform.ordering_service_info:
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) }}"
name: "{{ org.orderer.name }}"
register: os_info
- name: Store the ordering service in a file
copy:
content: "{{ os_info.ordering_service | to_nice_json }}"
dest: "{{ components_path }}/{{ org.orderer.name }}_Orderer.json"
- name: Retrieve MSP
ibm.blockchain_platform.organization_info:
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)}}"
name: "{{ org.msp.name }}"
register: msp_info
- name: Store MSP into a file
copy:
content: "{{ msp_info.organization | to_nice_json }}"
dest: "{{ components_path }}/{{ org.msp.name }}_MSP.json"
# This section onwards will enable V2 Capability
- name: Fetch the system channel configuration
ibm.blockchain_platform.channel_config:
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)}}"
operation: fetch
ordering_service: "{{ org.orderer.name }}"
identity: "{{ wallet_path }}/{{ org.msp.admin }}.json"
msp_id: "{{ org.msp.id }}"
name: "{{ os_info.ordering_service[0].system_channel_id }}"
path: "{{ channel_config_path }}/original_config.bin"
- name: Create a copy of the system channel configuration
copy:
src: "{{ channel_config_path }}/original_config.bin"
dest: "{{ channel_config_path }}/updated_config.bin"
- name: Enable Fabric v2.x capabilities
ibm.blockchain_platform.channel_capabilities:
path: "{{ channel_config_path }}/updated_config.bin"
channel: V2_0
orderer: V2_0
- name: Compute the system channel configuration update
ibm.blockchain_platform.channel_config:
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)}}"
operation: compute_update
ordering_service: "{{ org.orderer.name }}"
identity: "{{ wallet_path }}/{{ org.msp.admin }}.json"
msp_id: "{{ org.msp.id }}"
name: "{{ os_info.ordering_service[0].system_channel_id }}"
original: "{{ channel_config_path }}/original_config.bin"
updated: "{{ channel_config_path }}/updated_config.bin"
path: "{{ channel_config_path }}/config_update.bin"
register: compute_update
- name: Sign the system channel configuration update
ibm.blockchain_platform.channel_config:
operation: sign_update
identity: "{{ wallet_path }}/{{ org.msp.admin }}.json"
msp_id: "{{ org.msp.id }}"
name: "{{ os_info.ordering_service[0].system_channel_id }}"
path: "{{ channel_config_path }}/config_update.bin"
when: compute_update.path
- name: Apply the system channel configuration update
ibm.blockchain_platform.channel_config:
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)}}"
operation: apply_update
ordering_service: "{{ org.orderer.name }}"
identity: "{{ wallet_path }}/{{ org.msp.admin }}.json"
msp_id: "{{ org.msp.id }}"
name: "{{ os_info.ordering_service[0].system_channel_id }}"
path: "{{ channel_config_path }}/config_update.bin"
when: compute_update.path