Deploy Uptrace with Ansible

Ansible is an open source IT automation tool used for configuration management, application deployment, infrastructure provisioning, and orchestration. It allows you to automate repetitive tasks, deploy software, and manage systems in a consistent, reliable way.

This guide with help you install Uptrace on your bare metal servers along with all required dependencies. Before proceeding, please make sure you have Ansible installed on your system.

Getting started

Uptrace maintains a set of playbooks to deploy Uptrace with all required dependencies such as ClickHouse, PostgreSQL, and Redis.

To get Ansible playbooks, clone the repository:

shell
git clone https://github.com/uptrace/ansible.git
cd ansible

Inventory

An Ansible inventory is a file that defines the list of hosts (servers or nodes) that Ansible will manage and execute tasks on.

The repository comes with a sample YAML inventory which you should copy and fill with your hosts:

shell
cp inventory.yml.sample inventory.yml

Configuration

The configuration is stored in several locations:

  • group_vars/all.yml is the mian config that contains database passwords and some basic Uptrace configuration.
  • roles/uptrace/templates/config.yml contains the rest of Uptrace config.
  • Each roles also contains various templates, for example, ClickHouse config can be found at roles/clickhouse-server/templates/config.xml.

You need to copy the main config and then update the copy as needed:

shell
cp group_vars/all.yml.sample group_vars/all.yml

ClickHouse

Make sure you've updated all ch_* variables in group_vars/all.yml and then run:

yaml
ansible-playbook -i inventory.yml ch_server.yml

PostgreSQL

Make sure you've updated all pg_* variables in group_vars/all.yml and then run:

yaml
ansible-playbook -i inventory.yml pg.yml

Redis

To deploy Redis:

yaml
ansible-playbook -i inventory.yml redis.yml

Uptrace

To deploy Uptrace:

shell
ansible-playbook -i inventory.yml uptrace.yml

If all is good, you can ssh into the server to view the greeting from Uptrace:

shell
sudo journalctl -u uptrace -f

Use Uptrace documentation to review and update the configuration at roles/uptrace/templates/config.yml.

Let's Encrypt

Let's Encrypt uses the HTTP challenge to verify domain ownership. Therefore, you must ensure that your domain can be resolved using public DNS servers:

shell
nslookup my.domain.com

Then update your group_vars/all.yml file:

yaml
# Let's Encrypt will issue a certificate for this domain.
site_url: https://my.domain.com/

# Enable Let's Encrypt.
certmagic_enabled: true
# Use Let's Encrypt staging environment.
# Disable after testing that Let's Encrypt is working.
certmagic_staging_ca: true

# Listen on HTTPS port.
listen_http_addr: ':443'

Mailhog

Optionally, you can deploy Mailhog to view emails sent by Uptrace:

shell
ansible-playbook -i inventory.yml mailhog.yml

You should be able to view emails at http://localhost:8025.

Scaling

You can scale Uptrace by adding another host to your inventory.yml file:

yaml
uptrace:
  hosts:
    10.10.1.1: { primary: true }
    10.10.1.2:

And re-deploying Uptrace:

shell
ansible-playbook -i inventory.yml uptrace.yml