-
Notifications
You must be signed in to change notification settings - Fork 0
/
04-add-orgs-to-consortium.yaml
93 lines (86 loc) · 4 KB
/
04-add-orgs-to-consortium.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
---
- name: Add organizations to the consortium
hosts: localhost
vars_files:
- vars/common.yaml
- vars/organizations.yaml
- vars/channels.yaml
vars:
# os_org_name: os
org: "{{ vars['ordering_organization'][os_org_name] }}"
ordering_service_msp_admin: "{{ wallet_path }}/{{ org.msp.admin }}.json"
tasks:
- name: Get the ordering service information
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: Fail if ordering service does not exist
fail:
msg: "{{ org.orderer.name }} does not exist"
when: not os_info.exists
- 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: "{{ ordering_service_msp_admin }}"
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: Add the organization to the consortium
ibm.blockchain_platform.consortium_member:
state: present
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: "{{ peer_organizations[item].msp.name }}"
path: "{{ channel_config_path }}/updated_config.bin"
loop: "{{ consortium_members }}"
- 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: "{{ ordering_service_msp_admin }}"
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: "{{ ordering_service_msp_admin }}"
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: "{{ ordering_service_msp_admin }}"
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