Skip to main content

Automated network setup

This guide details the repository containing a script that automates the deployment of the Chromia network and four Postchain nodes on Amazon AWS. The script uses an Ansible playbook and you can modify it to fit your deployment requirements.

note

You should use this setup solely for demonstration or testing purposes. To secure production-grade networks, you need to implement additional measures, such as TLS support for the REST API of the Postchain nodes. You must also ensure proper log management and monitoring of the nodes. Additionally, never store provider keys on node servers in a production environment.

Prerequisites

The automated deployment script requires you to have:

  • Four AWS EC2 instances. You can modify the inventory file (/inventory/demo.yml) to decrease the number of deployed nodes.
  • Each instance needs to run Ubuntu 24.04.
  • Attach a secondary, unformatted disk to each server, in addition to the primary disk with the operating system.
  • Ensure that your virtual servers have public IP addresses.
  • Create DNS A records in the format: node0.my-network.domain.com, where node0 is the identifier of your node (e.g., node1, node2), pointing to the respective IP addresses of the virtual servers.

Repository files

FileDescription
/files/node.config.properties.j2This configuration file contains variables for private/public keys, network configuration, database, and container settings.
/files/pmc-config.j2This file holds variables for the node endpoint, private/public keys, and the BRID.
/files/postgres.conf.j2This file sets default configuration options in PostgreSQL's Docker image.
/inventories/demo.ymlThe Ansible inventory file lists variables for node and provider private/public keys and node configuration details.
/roles/docker/tasks/main.ymlThis configuration file installs Docker.
.env.exampleThis file contains environment variables for node and provider private/public keys.
network-setup.ymlThis file outlines the node network configuration details.

Deployment

Keys management

After cloning the repository, renaming the .env.example file to .env is your first step.

Next, add your hostname to the NETWORK_HOSTNAME parameter in the .env file.

If you already have provider and node keys, add them to the corresponding variables in the .env file. Otherwise, generate new key pairs using the following command:

pmc keygen

Inventory file

This step is optional: Modify the inventory file (/inventories/demo.yml) to fit your configuration requirements. Check that the values in providers, provider, clustersToHost, voter_sets, clusters, and clusters_economy are correct.

Running Ansible

We recommend using a Python environment to install and run Ansible to avoid system errors.

Execute the following commands to create a new environment and run the ansible-playbook with the specified inventory and network setup configuration files:

$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install ansible
$ ansible-playbook \
--inventory inventories/demo.yml \
network-setup.yml