The Principal Dev – Masterclass for Tech Leads

The Principal Dev – Masterclass for Tech LeadsJuly 17-18

Join

Autobase for PostgreSQL® :elephant: :sparkling_heart:

Ansible-lint Yamllint Flake8 Molecule GitHub license Open Bounties

Autobase for PostgreSQL® is an open-source alternative to cloud-managed databases (DBaaS) such as Amazon RDS, Google Cloud SQL, Azure Database, and more.

This automated database platform enables you to create and manage production-ready, highly available PostgreSQL clusters. It simplifies the deployment process, reduces operational costs, and makes database management accessible—even for teams without specialized expertise.

Automate deployment, failover, backups, restore, upgrades, scaling, and more with ease.

You can find a version of this documentation that is searchable and also easier to navigate at autobase.tech


Project Status

Autobase has been actively developed for over 5 years (since 2019) and is trusted by companies worldwide, including in production environments with high loads and demanding reliability requirements. Our mission is to provide an open-source DBaaS that delivers reliability, flexibility, and cost-efficiency.

The project will remain open-source forever, but to ensure its continuous growth and development, we rely on sponsorship. By subscribing to Autobase packages, you gain access to personalized support from the project authors and PostgreSQL experts, ensuring the reliability of your database infrastructure.


Supported setups of Postgres Cluster

pg_cluster_scheme

You have three schemes available for deployment:

1. PostgreSQL High-Availability only

This is simple scheme without load balancing.

Components:

2. PostgreSQL High-Availability with Load Balancing

This scheme enables load distribution for read operations and also allows for scaling out the cluster with read-only replicas.

When deploying to cloud providers such as AWS, GCP, Azure, DigitalOcean, and Hetzner Cloud, a cloud load balancer is automatically created by default to provide a single entry point to the database (controlled by the cloud_load_balancer variable).

For non-cloud environments, such as when deploying on Your Own Machines, the HAProxy load balancer is available for use. To enable it, set with_haproxy_load_balancing: true variable.

[!NOTE] Your application must have support sending read requests to a custom port 5001, and write requests to port 5000.

List of ports when using HAProxy:

Components of HAProxy load balancing:

3. PostgreSQL High-Availability with Consul Service Discovery

To use this scheme, specify dcs_type: consul variable.

This scheme is suitable for master-only access and for load balancing (using DNS) for reading across replicas. Consul Service Discovery with DNS resolving is used as a client access point to the database.

Client access point (example):

Besides, it can be useful for a distributed cluster across different data centers. We can specify in advance which data center the database server is located in and then use this for applications running in the same data center.

Example: replica.postgres-cluster.service.dc1.consul, replica.postgres-cluster.service.dc2.consul

It requires the installation of a consul in client mode on each application server for service DNS resolution (or use forward DNS to the remote consul server instead of installing a local consul client).

Compatibility

RedHat and Debian based distros (x86_64)

Supported Linux Distributions:
PostgreSQL versions:

all supported PostgreSQL versions

:white_check_mark: tested, works fine: PostgreSQL 10, 11, 12, 13, 14, 15, 16, 17

Table of results of daily automated testing of cluster deployment:

Distribution Test result
Debian 11 GitHub Workflow Status
Debian 12 GitHub Workflow Status
Ubuntu 22.04 GitHub Workflow Status
Ubuntu 24.04 GitHub Workflow Status
CentOS Stream 9 GitHub Workflow Status
Oracle Linux 8 GitHub Workflow Status
Oracle Linux 9 GitHub Workflow Status
Rocky Linux 8 GitHub Workflow Status
Rocky Linux 9 GitHub Workflow Status
AlmaLinux 8 GitHub Workflow Status
AlmaLinux 9 GitHub Workflow Status

Getting Started

You have the option to deploy Postgres clusters using the Console (UI), command line, or GitOps.

[!TIP] 📩 Contact us at info@autobase.tech, and our team will help you implement Autobase into your infrastructure.

Console (UI)

The Autobase Console (UI) is the recommended method for most users. It is designed to be user-friendly, minimizing the risk of errors and making it easier than ever to set up your PostgreSQL clusters. This method is suitable for both beginners and those who prefer a visual interface for managing their PostgreSQL clusters.

To run the autobase console, execute the following command:

docker run -d --name autobase-console \
  --publish 80:80 \
  --publish 8080:8080 \
  --env PG_CONSOLE_API_URL=http://localhost:8080/api/v1 \
  --env PG_CONSOLE_AUTHORIZATION_TOKEN=secret_token \
  --env PG_CONSOLE_DOCKER_IMAGE=autobase/automation:latest \
  --volume console_postgres:/var/lib/postgresql \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume /tmp/ansible:/tmp/ansible \
  --restart=unless-stopped \
  autobase/console:latest

[!NOTE] If you are running the console on a dedicated server (rather than on your laptop), replace localhost with the server’s IP address in the PG_CONSOLE_API_URL variable.

[!TIP] It is recommended to run the console in the same network as your database servers to enable monitoring of the cluster status.

Alternatively, you can use Docker Compose.

Open the Console UI:

Go to http://localhost:80 (or the address of your server) and use secret_token for authorization.

Cluster creation demo

Refer to the Deployment section to learn more about the different deployment methods.

Command line

Click here to expand... if you prefer the command line.

The command line mode is suitable for advanced users who require greater flexibility and control over the deployment and management of their PostgreSQL clusters. While the Console (UI) is designed for ease of use and is suitable for most users, the command line provides powerful options for those experienced in automation and configuration.

  1. Install Ansible on one control node (which could easily be a laptop)
sudo apt update && sudo apt install -y python3-pip sshpass git
pip3 install ansible
  1. Install the Autobase Collection

Install directly from Ansible Galaxy:

ansible-galaxy collection install vitabaks.autobase

Or include it in your requirements.yml:

collections:
  - name: vitabaks.autobase
    version: 2.2.0
  1. Prepare your inventory

See the example inventory file. Specify internal IP addresses and connection details such as ansible_user, ansible_ssh_pass, or ansible_ssh_private_key_file.

  1. Define variables

Review default variables. Override them in your inventory, group_vars, or other appropriate locations.

  1. Use Autobase playbook
- name: Run Autobase deployment
  ansible.builtin.include_playbook: vitabaks.autobase.deploy_pgcluster

Note: Start with deploy_pgcluster, and use config_pgcluster later for reconfiguration.

How to start from scratch

If you need to start from the very beginning, you can use the remove_cluster playbook.

Available variables:

⚠️ Caution: Only use this in non-production or when you’re absolutely sure.

Star us

If you find our project helpful, consider giving it a star on GitHub! Your support helps us grow and motivates us to keep improving. Starring the project is a simple yet effective way to show your appreciation and help others discover it.

Star History Chart

By sponsoring our project, you directly contribute to its continuous improvement and innovation. As a sponsor, you'll receive exclusive benefits, including personalized support, early access to new features, and the opportunity to influence the project's direction. Your sponsorship is invaluable to us and helps ensure the project's sustainability and progress.

Become a sponsor today and help us take this project to the next level!

Support our work through GitHub Sponsors

GitHub Sponsors

Support our work through Patreon

Support me on Patreon

License

Licensed under the MIT License. See the LICENSE file for details.

Author

Vitaliy Kukharik (PostgreSQL DBA)
vitaliy@autobase.tech

Feedback, bug-reports, requests, ...

Are welcome!

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.