2021 Call for Code Awards: Live from New York, with SNL’s Colin Jost! Learn more

Provision Hyperledger Fabric on multiple VMs using Ansible

With the growing popularity of blockchain solutions such as Hyperledger Fabric, the ability to quickly stand up customized networks to solve specific business problems is increasing. The currently available provisioning examples generally focus on provisioning a network on a single virtual machine, creating overly simplistic network configurations that may not reflect actual performance on a distributed network.

At IBM Research – Ireland, we have built a set of open source provisioning examples, available on GitHub, that allow you to quickly:

  • Provision and test customized blockchain network configurations with minimal effort
  • Test distributed networks using multiple VMs in a short amount of time
  • Reuse parts of these examples to build your own provisioning tools

These provisioning examples are built for general application and are business-domain agnostic. They are designed to make it easier to get a distributed network up and running faster, supporting blockchain architects, system administrators, and senior developers charged with setting up Hyperledger Fabric networks.

Providing persistent network and flexibility in customizing a blockchain network

The new provisioning examples provide:

  • A starting point for architects, network administrators, and senior developers
  • Sample code that provides a large amount of flexibility for provisioning custom networks
  • A persistent and fault-tolerant network
  • Extensibility for the user to grow and harden these examples from minimum viable product to full testing to production code

The design ethos behind these examples is that everything is built with a conservative bias toward provisioning a network. Each participating organization provides their copy of the components to run a Hyperledger Fabric network (meaning it doesn’t rely on another organization to provide essential components, such as identity). In this design, each organization provides its own Zookeeper, Kafka, peer, orderer, and fabric-ca nodes.

Getting started

You can find examples of provisioning a Hyperledger Fabric network on GitHub. These two examples cover the simple case of a single peer and solo orderer, and then a fully distributed and more robust Fabric network.

Single peer/solo orderer

The first example shows you how to bring up the most minimal functioning Fabric network: a single peer and a single solo orderer. The purpose of this example is to expose and highlight the artifacts (correct certificates, YAML config files, and environment variables) required to have a working peer and orderer.

The repository contains the most basic, minimal network possible using a native peer binary and its configuration files, with a native solo orderer binary and its configuration files. It also includes some scripts and their environment variables to:

  • Create and join a channel
  • Install and instantiate chaincode
  • Invoke and query the chaincode

This is in the ./single directory in our GitHub repository.

Figure 1. Fabric network with single peer and solo orderer

Fabric network with single peer and solo orderer

This first example equips you with:

  • A simple network and shows the files needed for each component
  • A transparent approach — everything is contained in a single, easy-to-follow script

Perhaps most importantly, this first example shows the minimum requirements (in terms of configuration files, environment variables, and certificates) that are required for a functioning peer and orderer. All of this is contained in a single shell script that is intentionally simplified while also being intentionally verbose, in the hopes of adding clarity to the provisioning process.

Distributed multi-org example

The second example is much more involved. It uses Ansible to create three or more organisations, where each organisation consists of a Zookeeper node, a Kafka node, a fabric-ca node, an orderer node, N peer nodes, and a client node. Each node corresponds to its own virtual machine. You will find this example in the ./ansible directory in the GitHub repository.

Figure 2. Distributed multi-org example

Distributed multi-org example

Using the template of the first example, the second example creates a fully distributed and more robust Hyperledger Fabric network. This is created for a user-defined number of organisations and peers per organisation. It generates the necessary config files automatically. Since setting up this kind of network would be a tedious and error-prone process if done manually, an Ansible playbook is provided, addressing the numerous roles required for the network.

The Hyperledger Fabric components run on separate VMs, which are provided by SoftLayer. This entry outlines how to provision, using Ansible, Hyperledger Fabric native binaries on multiple SoftLayer VMs.

Next steps: Try it

Try our set of provisioning examples out and give us your feedback. Our hope is that these examples will prove educational and beneficial to the broad Hyperledger Fabric community.