Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Trust Wallet's Ansible Galaxy Collection of roles to configure blockchain nodes.

License

Notifications You must be signed in to change notification settings

trustwallet/ansible-collection-blockchain

Repository files navigation

Ansible Collection - trustwallet.blockchain

🛡️ Trust Wallet is a most trusted & secure non-custodial crypto wallet.

The Trust Wallet's Ansible Galaxy collection of roles to configure blockchain nodes.

NOTE: These roles set up non-validator nodes. Please check the requirements and an additional configuration at the chain's documentation if the validator or other node type is required.

List of the collection roles:

Ansible Collection Usage

Install the collection using the following command:

ansible-galaxy collection install trustwallet.blockchain

Example setting up Ethereum Full Node with the collection role:

# playbook.yml
---
- hosts: "all"
  gather_facts: true
  become: true
  
  pre_tasks:
    - name: "Install apt packages"
      ansible.builtin.apt:
        update_cache: true
        cache_valid_time: 86400
        pkg: python3
  
  roles:
    - role: trustwallet.blockchain.ethereum
      data_dir: /mnt/data
      geth_config:
        Eth:
          SyncMode: full

Concept

Ansible Roles consists of few phases (not every role contains all phase though):

  • load variables
  • install binaries
  • init blockchain node
  • set configuration
  • sync chain data from public backup

Contributing

The best way to submit feedback and report bugs is to open a GitHub issue.

Development

Molecule Testing Framework

Development/integration of the roles are configured with Molecule and EC2 driver.

It's recommended to develop inside Virtual environment

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
ansible-galaxy install -r requirements.yml

Provide AWS credentials to allow Molecule provision ephemeral EC2 instance.

export AWS_PROFILE=
# or 
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_KEY=

Also provide the target region, image AMI and VPC subnet identifier

export AWS_REGION=us-east-1
export MOLECULE_VPC_SUBNET_ID=subnet-...
export MOLECULE_IMAGE=ami-... # ubuntu
export MOLECULE_IMAGE_DEBIAN=ami-... # debian for blockbook 

For each role there is a /molecule/<role> directory with configuration files.

Execute full integration scenario which includes steps to install all dependencies, create EC2 instance, execute role, test, cleanup and finally destroy EC2 instance run the following command (e.g. ethereum role).

molecule test -s ethereum

Or launch instance and execute a role

molecule converge -s ethereum

And verify

molecule verify -s ethereum

Jump to the node

molecule login -s ethereum

Finally, cleanup and destroy

molecule destroy -s ethereum

Build Ansible Galaxy Locally

To build the local version of the Ansible Galaxy collection:

ansible-galaxy collection build --force

The trustwallet-blockchain-x.x.x.tar.gz file will appear at the root of the project.

It can be installed for local testing by executing the following command:

ansible-galaxy collection install trustwallet-blockchain-0.x.x.tar.gz --force

References

License

Ansible Collection trustwallet.blockchain is available under the MIT license.