File tree Expand file tree Collapse file tree 8 files changed +29
-17
lines changed
fabric-chaincode-lifecycle/templates
fabric-osnadmin-channel-create/templates
create/new_orderer/create_syschannel_block/templates
shared/configuration/roles/create/job_component/templates Expand file tree Collapse file tree 8 files changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ metadata:
1919 annotations :
2020 helm.sh/hook-weight : " -5"
2121 helm.sh/hook : " pre-install,pre-upgrade"
22- helm.sh/hook-delete-policy : " before-hook-creation,hook-succeeded "
22+ helm.sh/hook-delete-policy : " before-hook-creation"
2323spec :
2424 backoffLimit : 6
2525 template :
Original file line number Diff line number Diff line change @@ -207,10 +207,12 @@ spec:
207207
208208 #!/usr/bin/env sh
209209 echo "Format or fetch genesis file..."
210+
210211 if [ $ADD_ORDERER = false ]
211212 then
212213 cat ./genesis/genesis.block.base64 | base64 -d > orderer.genesis.block
213- else
214+ else
215+ echo "Updating orderer configs..."
214216 peer channel fetch config ${CHANNEL_NAME}_config_block.pb -o ${CORE_PEER_ADDRESS} -c ${CHANNEL_NAME} --tls --cafile ${ORDERER_CA}
215217 fi
216218
Original file line number Diff line number Diff line change 1919 gather_facts : no
2020 no_log : " {{ no_ansible_log | default(false) }}"
2121 tasks :
22-
23- # delete build directory
24- - name : Remove build directory
25- file :
26- path : " ./build"
27- state : absent
28-
2922 # Generate script to modify the fetched configuration block
3023 - include_role :
3124 name : " create/new_organization/create_block"
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ rm -r temp
1717echo " converting the channel_config_block.pb to channel_config.json using configtxlator and jq"
1818configtxlator proto_decode --input {{ channel_name }}_config_block.pb --type common.Block | jq .data.data[0].payload.data.config > {{ channel_name }}_config.json
1919echo " adding new organization crypto material from config.json to the channel_config.json to make channel_modified_config.json"
20- jq --argjson a " $( cat ./orderer) " ' .channel_group.values.OrdererAddresses.value.addresses += $a' {{ channel_name }}_config.json > {{ channel_name }}_modified_config.json
20+ jq --argjson a " $( cat ./orderer) " ' .channel_group.groups.Orderer. values.OrdererAddresses.value.addresses += $a' {{ channel_name }}_config.json > {{ channel_name }}_modified_config.json
2121echo " converting the channel_config.json and channel_modified_config.json to .pb files"
2222configtxlator proto_encode --input {{ channel_name }}_config.json --type common.Config --output {{ channel_name }}_config.pb
2323configtxlator proto_encode --input {{ channel_name }}_modified_config.json --type common.Config --output {{ channel_name }}_modified_config.pb
Original file line number Diff line number Diff line change 2020 loop : " {{ participants }}"
2121 loop_control :
2222 loop_var : participant
23- when : participant.type == 'creator '
23+ when : participant.org_status == 'existing '
2424
2525# Start the cli, configure and download the configuration block
2626- name : Call nested_fetch_role for the peer
3737 loop : " {{ participants }}"
3838 loop_control :
3939 loop_var : participantx
40- when : participantx.type == 'creator '
40+ when : participantx.org_status == 'existing '
Original file line number Diff line number Diff line change 5050 loop_var : org_new
5151 when : org_new.org_status == 'new'
5252
53+ # Check if channel block0 file exists
54+ - name : Check if the channel_block0_fetched file exists
55+ stat :
56+ path : " ./build/{{ channel_name | lower }}_block0_fetched"
57+ register : block0_file
58+
5359# Fetch the config block from blockchain by executing the create_block.sh script file
54- # from first peer of creator cli
60+ # from the peer of first approving org
5561- name : Fetch and copy the configuration block from the blockchain
5662 shell : |
5763 export PEER_CLI=$(KUBECONFIG={{ org.k8s.config_file }} kubectl get po -n {{ org.name }}-net | grep "cli" | head -n 1 | awk '{print $1}')
6268 KUBECONFIG={{ kubernetes.config_file }} kubectl exec -n {{ org.name }}-net ${PEER_CLI} -- chmod 777 ./create_block.sh
6369 KUBECONFIG={{ kubernetes.config_file }} kubectl exec -n {{ org.name }}-net ${PEER_CLI} -- sh ./create_block.sh
6470 KUBECONFIG={{ kubernetes.config_file }} kubectl cp {{ org.name }}-net/${PEER_CLI}:/opt/gopath/src/github.com/hyperledger/fabric/peer/{{ channel_name | lower }}_update_in_envelope.pb ./build/{{ channel_name | lower}}_config_block.pb
71+ touch ./build/{{ channel_name | lower }}_block0_fetched
6572 environment :
6673 ORDERER_CA : " /opt/gopath/src/github.com/hyperledger/fabric/orderer/tls/orderer.crt"
6774 vars :
6875 kubernetes : " {{ org.k8s }}"
76+ when : not block0_file.stat.exists
Original file line number Diff line number Diff line change 5454 retries : 5
5555 delay : 10
5656
57+ # Delete the build folder if channel update is successful
58+ - name : Delete the build folder
59+ ansible.builtin.file :
60+ path : ./build
61+ state : absent
62+ when : update_channel is succeeded
63+
5764# Delete the cli
5865- name : " Delete cli {{ peer.name }}-{{ participant.name }}-cli"
5966 shell : |
Original file line number Diff line number Diff line change @@ -33,14 +33,16 @@ orderers:
3333 - name: {{ value }}
3434 adminAddress: {{ value }}. {{ component_ns }}:7055
3535{% endif %}
36+ {% if key == 'ordererAddress' %}
37+ ordererAddress: {{ value }}
38+ {% endif %}
3639{% endfor %}
3740{% endfor %}
3841
39- addOrderer: {{ add_orderer_value }}
40-
41- {% if add_orderer_value is defined and add_orderer_value is sameas true %}
42+ {% if add_orderer_value is defined and add_orderer_value %}
4243orderer:
44+ addOrderer: {{ add_orderer_value }}
4345 name: {{ first_orderer.name }}
4446 localMspId: {{ org.name | lower}}MSP
45- address : {{ existingOrdererAddress }}
47+ ordererAddress : {{ existingOrdererAddress }}
4648{% endif %}
You can’t perform that action at this time.
0 commit comments