Skip to content

stakemachine/thegraph-ansible

Repository files navigation

The Graph Indexer Ansible

Collection of ansible playbooks and roles to operate The Graph Indexer infrastructure.

WARNING: var files contain sensitive information, keep them safe or encrypt with ansible vault

Demo

asciicast

Overview

This repo contains a number of roles and playbooks to run any kind of Indexer infrastructure deployments.

Sample playbooks will show you how to use roles to run all components on a single node or provision infrastructure to multiple nodes.

Prerequisites

Make sure you have installed all of the following prerequisites on your machine:

Make sure that all servers have your ssh autorized_keys in place, so you won't be asked for a password during provisioning. If you don't have any keys, here is the easiest way to generate them and add them to your servers is to use ssh-copy-id.

Tested on

  • Ubuntu 20.04

Roles

  • graph-node
  • indexer-agent
  • indexer-service
  • postgres-docker
  • prometheus
  • grafana-docker
  • vector-docker
  • wireguard
  • geerlingguy.postgresql
  • geerlingguy.docker
  • geerlingguy.pip
  • geerlingguy.firewall

Sample playbooks

Before using sample playbooks you need to install the required roles:

ansible-galaxy install -r requirements.yml

Single Node

Configuration

It's necessary to adjust few variables before running an Indexer.

Variables

Copy an example

cp vars/single-node-testnet.yml.example vars/single-node-testnet.yml

Adjust variables in vars/single-node-testnet.yml

Inventory

Copy an example

cp single-node.inventory.example single-node.inventory

Set an IP address of your server in single-node.inventory

Run playbook
ansible-playbook -i single-node.inventory single-node-testnet.yml -u root -e @vars/single-node-testnet.yml

Multi-node

Configuration

Multi-node configuration is a bit more complicated because of the Wireguard VPN setup.
But it's also possible to run without the wireguard but with a local network instead.

Variables

Copy an example

cp vars/multi-node-testnet.yml.example vars/multi-node-testnet.yml

Adjust variables in vars/multi-node-testnet.yml

Inventory

Copy an example

cp multi-node.inventory.example multi-node.inventory

Set an IP address of your servers in multi-node.inventory. Generate pairs of keys for each server and set them at the bottom of inventory file.
To generate a pair of keys you can use these commands:

private_key=$(wg genkey)
public_key=$(echo $private_key | wg pubkey)
echo "private key: $private_key"
echo "public key: $public_key"
Run playbook
ansible-playbook -i multi-node.inventory multi-node-testnet.yml -u root -e @vars/multi-node-testnet.yml

Generate wireguard config to connect to network:

ansible-playbook -i multi-node.inventory wg_local.yml -u root

Useful commands

Check if nodes are accessible

ansible thegraph -m ping -i multi-node.inventory -u root

Check containers and their states:

docker ps

Check container logs:

docker logs --tail 20 <container-name>

Contributing

Contributions are always welcome!

Authors

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages