Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix #322

Merged
merged 3 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/operations/adding_new_org_fabric.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ network:
<a name = "run_network"></a>
## Run playbook to add the new organization to the existing Hyperledger Fabric network

The [add-organization.yaml](https://github.com/hyperledger-labs/blockchain-automation-framework/tree/master/platforms/hyperledger-fabric/configuration/add-organization.yaml) playbook is used to add a new organization to the existing network. This can be done using the following command
The [add-new-organization.yaml](https://github.com/hyperledger-labs/blockchain-automation-framework/tree/master/platforms/shared/configuration/add-new-organization.yaml) playbook is used to add a new organization to the existing network. This can be done using the following command

```
ansible-playbook platforms/hyperledger-fabric/configuration/add-organization.yaml --extra-vars "@path-to-network.yaml"
ansible-playbook platforms/shared/configuration/add-new-organization.yaml --extra-vars "@path-to-network.yaml"
```

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# This task fetches the configtx gen tar file from the mentioned URL
- name: "Geting the configtxgen binary tar"
get_url:
url: https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/{{fabric.os}}-{{fabric.arch}}-{{network.version}}/hyperledger-fabric-{{fabric.os}}-{{fabric.arch}}-{{network.version}}.tar.gz
url: https://github.com/hyperledger/fabric/releases/download/v{{network.version}}/hyperledger-fabric-{{fabric.os}}-{{fabric.arch}}-{{network.version}}.tar.gz
dest: "{{ tmp_directory.path }}"
when: config_stat_result.stat.exists == False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
when: vault_msp_result.failed == True

############################################################################################
# This task installs dos2unix on the Ansible container
- name: "Install dos2unix to use unarchieve module of ansible"
apt:
name: dos2unix
when: vault_msp_result.failed == True

# Copy generate-crypto script from scrips directory
- name: Copy generate-usercrypto.sh to destination directory
copy:
Expand All @@ -50,7 +44,6 @@
# This task converts the generate_crypto.sh file to unix format
- name: Convert the file to unix format
sownak marked this conversation as resolved.
Show resolved Hide resolved
shell: |
dos2unix ./build/{{ files }}
chmod 755 ./build/{{ files }}
with_items:
- "generate-crypto-{{ org_name|lower }}-{{ orderer.name }}.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
when: vault_msp_result.failed == True

############################################################################################
# This task installs dos2unix on the Ansible container
- name: "Install dos2unix to use unarchieve module of ansible"
apt:
name: dos2unix
when: vault_msp_result.failed == True

# Copy generate-crypto script from scrips directory
- name: Copy generate-usercrypto.sh to destination directory
copy:
Expand All @@ -35,7 +29,6 @@
# This task converts the generate_crypto.sh file to unix format
- name: Convert the file to unix format
sownak marked this conversation as resolved.
Show resolved Hide resolved
shell: |
dos2unix ./build/{{ files }}
chmod 755 ./build/{{ files }}
with_items:
- "generate-crypto-{{ org_name|lower }}.sh"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apt-get install -y jq
echo "installing configtxlator"
mkdir temp
cd temp/
wget https://nexus.hyperledger.org/content/repositories/releases/org/hyperledger/fabric/hyperledger-fabric/{{ os }}-{{ arch }}-{{ version }}/hyperledger-fabric-{{ os }}-{{ arch }}-{{ version }}.tar.gz
wget https://github.com/hyperledger/fabric/releases/download/v{{ version }}/hyperledger-fabric-{{ os }}-{{ arch }}-{{ version }}.tar.gz
tar -xvf hyperledger-fabric-{{ os }}-{{ arch }}-{{ version }}.tar.gz
mv bin/configtxlator ../
cd ../
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@

### Tasks
(Variables with * are fetched from the playbook which is calling this role)
#### 1. Call nested_sign_and_update for each peer

#### 1. Call valuefile when participant is new
This task calls valuefile
##### Input Variables
**include_tasks**: It includes the name of intermediatory task which is required for creating the value file for cli of peer, starting the cli and signing the block
**loop**: loops over result list fetched from *channel_participants*
**loop_control**: Specify conditions for controlling the loop.

loop_var: loop variable used for iterating the loop.

#### 2. Call nested_sign_and_update for each peer
This task calls nested_sign_and_update
##### Input Variables
*channel_name: Name of the channel
Expand Down Expand Up @@ -138,3 +148,32 @@ This task creates the cli for the creator organization first peer.
*config_file: Kubernetes file


------------
### valuefile.yaml
This task performs a check if the new organization peers are up

### Tasks
#### 1. Check peer pod is up
This task creates valuefile for the peer.
##### Input Variables

*org_query: New organization information
*peer_data: Peer information

**include_tasks**: It includes the name of intermediatory task which is required for creating the value file for cli of peer, starting the cli and signing the block
**loop**: loops over result list fetched from *channel_participants*
**loop_control**: Specify conditions for controlling the loop.

loop_var: loop variable used for iterating the loop.

------------
### peercheck.yaml
This task performs a check if the new organization peers are up

### Tasks
#### 1. Check peer pod is up
This task creates valuefile for the peer.
##### Input Variables

*namespace: Namespace of the new organization
*kubeconfig: Kubeconfig information
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
# This task calls nested_sign_and_update and nested_update_channel tasks
############################################################################################

# Check or wait for the peer
- name: Call valuefile when participant is new
include_tasks: valuefile.yaml
vars:
channelcreator_query: "participants[?org_status=='new']"
loop: "{{ item | json_query(channelcreator_query) }}"
loop_control:
loop_var: peer

# Task for creating the cli for first peer of each organization
# Config block gets signed by the admin of every organization
- name: Call nested_sign_and_update for each peer
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
- name: "Check peer pod is up"
k8s_facts:
kind: Pod
namespace: "{{ org.name | lower }}-net"
kubeconfig: "{{ org.k8s.config_file }}"
context: "{{ org.k8s.context }}"
label_selectors:
- app = {{ peer_name }}
loop: "{{ peers_data | from_yaml }}"
loop_control:
loop_var: peer_name
register: get_peer
until: ("Running" in get_peer|json_query('resources[*].status.phase'))
retries: "{{ network.env.retry_count}}"
delay: 40
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
############################################################################################
# This task is the nested task for main.yaml which helps to create a check for peers for new organization

# Check or wait for the peer
- name: "Check peer pod is up"
include_tasks: peercheck.yaml
vars:
org_query: "organizations[?name=='{{peer.name}}']"
peers_data: "{{ peer | json_query('peers[*].name') }}"
loop: "{{ network | json_query(org_query) }}"
loop_control:
loop_var: org
19 changes: 19 additions & 0 deletions platforms/shared/configuration/add-new-organization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
#######################################
# Master Playbook for the setting up and reseting the Blockchain Automation Framework DLT network
#######################################
- hosts: all
gather_facts: no
- import_playbook: environment-setup.yaml # First setup environment for each organization
- import_playbook: kubernetes-env-setup.yaml # Then deploy Flux for each organization
when: reset is undefined or reset == 'false'
- import_playbook: "{{ playbook_dir }}/../../hyperledger-fabric/configuration/add-organization.yaml"
when: network.type == 'fabric' and (reset is undefined or reset == 'false')
- import_playbook: "{{ playbook_dir }}/../../r3-corda/configuration/deploy-network.yaml"
when: network.type == 'corda' and (reset is undefined or reset == 'false')

# Reseting the network
- import_playbook: "{{ playbook_dir }}/../../r3-corda/configuration/reset-network.yaml"
sownak marked this conversation as resolved.
Show resolved Hide resolved
when: network.type == 'corda' and reset is defined and reset == 'true'
- import_playbook: "{{ playbook_dir }}/../../hyperledger-fabric/configuration/reset-network.yaml"
when: network.type == 'fabric' and reset is defined and reset == 'true'