This is an open-source project and is not officially supported by EDB Support. This repository is maintained and supported by the EDB GitHub members of this repository. Please provide feedback by posting issues and contribute by creating pull requests.
This Ansible Galaxy Collection brings reference architecture deployment capabilites for PostgreSQL or EnterpriseDB Postgres Advanced Server.
Not all Distribution or versions are supported on all the operating systems available.
The ansible playbook must be executed under an account that has full privileges.
edb-ansible
is a repository used for hosting an Ansible Collection that
currently supports the following ansible roles:
A role for setting up the EDB and PG Community and EPEL repositories. For installation of these repositories, role needs outbound connections to internet, mainly connection to the following sites:
1. yum.enterprisedb.com
2. download.postgresql.org
3. dl.fedoraproject.org
This role requires following compulsory parameters:
pg_type
: "EPAS" or "PG"repo_username
: EDB repository's usernamerepo_password
: EDB yum repository's password.
For access to EDB repository, you can use following link: EDB yum access
A role for installing EPAS/PG database server packages. This role installs the EPAS/PG packages, depending on the values of the following variables in the playbook.yml:
pg_type
: EPAS/PG- And
pg_version
: EPAS/PG major version number
A role for initializing the PG/EPAS cluster(data) directory.
This role allows users to pass following variables:
pg_type
: EPAS/PGpg_version
: EPAS/PG Version. Default is 12.pg_data
: EPAS/PG data directory. Default is /var/lib/edb/as{pg_version}/datapg_wal
: EPAS/PG wal location. Default is /var/lib/edb/as{pg_version}/data/pg_walpg_ssl
: For configuration of data directory with SSL
For more information on variables, please refer to the following variables file:
- EPAS variables: roles/init_dbserver/vars/EPAS.yml
- And, PG variables: roles/init_dbserver/vars/PG.yml
For more information on the role, please refer roles README README.md
A role for setting up the replication (synchronous/asynchronous).
Similar to init_dbserver
role, setup_replication
has following variables
for managing the EPAS/PG.
pg_type
: EPAS/PGpg_version
: EPAS/PG Version. Default is 12.pg_data
: EPAS/PG data directory. Default is /var/lib/edb/as{pg_version}/datapg_wal
: EPAS/PG wal location. Default is /var/lib/edb/as{pg_version}/data/pg_walpg_replication_user
: Replication user for replicating data between primary and standby. Default is repuserpg_replication_user_password
: Replication user password. Default auto generated and stored on localhost under~/.edb/<pg_replication_user_password>_pass
For more information on the role, please refer roles README README.md
A role for setting up EDB Failover Manager for Postgres/EPAS HA cluster.
In the playbook, user can choose the specific roles based on their requirement. For more information on the role, please refer roles README README.md
This role helps in setting PEM Server. For more information on the role, please refer roles README README.md
This role helps in setting and deployment of PEM Agent on the PG/EPAS servers. For more information on the role, please refer roles README README.md
This role helps in managing the HA cluster and covers common tasks. For more information on the role, please refer roles README README.md
This role install and configure a new PgBouncer connection pooler. For more information on the role, please refer roles README README.md
This role helps in managing PgBouncer connection pools list and users. For more information on the role, please refer roles README README.md
This role install and configure a new PgpoolII connection pooler. For more information on the role, please refer roles README README.md
This role helps in managing Pgpool II user list and configuration. For more information on the role, please refer roles README README.md
Setting up Barman server role. README.md
Configure Postgres backups with Barman. README.md
The autotuning role configures the system and Postgres instances for optimal performances. Most of the configuration values are calculated automatically from available resources found on the system. README.md
For correctly installed and configuration of the cluster following are requirements:
- Following are ports which should be opened for communication between the servers:
* Postgres: **5432**
* EDB Postgres Advanced Server Port: **5444**
* EDB Failover Manager: **7800-7810**
Note: If you have firewall enabled on the server, then please allow the access through above ports.
- Ansible (on the machine on which playbook will be executed).
- Operating system privileged user (user with sudo privilege) on all the servers/virtual machines.
- Instances for the Postgres or EPAS cluster should have at least 2 CPUs and 4 GB of RAM
- The instance utilized for deploying with ansible can be a minimal instance
Note: In our examples, we have used centos
user for Centos OS and
ec2_user
for RHEL OS as a privileged user.
- To install Ansible: Installing Ansible
- A CLI or SDK depending on the Cloud vendor to utilize is required:
- To install the Amazon Web Services CLI please refer to: Installing the AWS CLI
- To install the Microsoft Azure CLI please refer to: Installing the AZURE CLI
- To install the Google Cloud SDK please refer to: Installing the Google Cloud SDK
The edb_ansible
Ansible collection can be installed in 3 different approaches:
Installing the edb_postgres
Ansible Collection is done by following the steps
below:
- Open the command line
- Type:
$ ansible-galaxy collection install edb_devops.edb_postgres --force
- Press Enter
This approach automatically makes the edb_postgres
collection available to
your playbooks.
A message indicating where the collection is installed will be displayed by ansible-galaxy. The collection code should be automatically made readily available for you.
By default the location of your installed collection is:
~/.ansible/collections/ansible_collections
This method requires to have the ansible-galaxy
tool installed.
Downloading the code from the repository can be accomplished by following the steps below:
- Navigate to the repository address:
https://github.com/EnterpriseDB/edb-ansible
- Click on the green Code Button located next to the About section
- Click on the Download Zip Link menu option
After the code has been downloaded, the code will be available as a zip file which requires being unzipped to your desired target destination.
After the code has been unzipped, you must go to root folder
edb-ansible-master
, and install the collection by entering the command below:
$ make install
This approach automatically makes the edb_postgres
collection available to
your playbooks.
A message indicating where the collection is installed will be displayed by ansible-galaxy. The collection code should be automatically made readily available for you.
By default the location of your installed collection is:
~/.ansible/collections/ansible_collections
This method requires to have the ansible-galaxy
tool installed.
Downloading the code from the repository can be accomplished by following the steps below:
$ git clone [email protected]:EnterpriseDB/edb-ansible.git
After the code has been downloaded, the code will be available in your current
directory within a directory named: edb-ansible
.
You can access the root folder of the repository by entering the command below:
$ cd edb-ansible
You can install the collection by entering the command below:
$ make install
This approach automatically makes the edb_postgres
collection available to
your playbooks.
A message indicating where the collection is installed will be displayed by ansible-galaxy. The collection code should be automatically made readily available for you.
By default the location of your installed collection is:
~/.ansible/collections/ansible_collections
Content of the inventory.yml
file:
---
all:
children:
pemserver:
hosts:
pemserver1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
primary:
hosts:
primary1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
pem_agent: true
pem_server_private_ip: xxx.xxx.xxx.xxx
standby:
hosts:
standby1:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
upstream_node_private_ip: xxx.xxx.xxx.xxx
replication_type: synchronous
pem_agent: true
pem_server_private_ip: xxx.xxx.xxx.xxx
standby2:
ansible_host: xxx.xxx.xxx.xxx
private_ip: xxx.xxx.xxx.xxx
upstream_node_private_ip: xxx.xxx.xxx.xxx
replication_type: asynchronous
pem_agent: true
pem_server_private_ip: xxx.xxx.xxx.xxx
Below is an example of how to include all the roles for a deployment in a playbook:
---
- hosts: all
name: Postgres deployment playbook
become: yes
gather_facts: yes
collections:
- edb_devops.edb_postgres
pre_tasks:
- name: Initialize the user defined variables
set_fact:
pg_version: 13
pg_type: "PG"
repo_username: ""
repo_password: ""
disable_logging: false
roles:
- role: setup_repo
when: "'setup_repo' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: install_dbserver
when: "'install_dbserver' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: init_dbserver
when: "'init_dbserver' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_replication
when: "'setup_replication' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_efm
when: "'setup_efm' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_pgpool2
when: "'setup_pgpool2' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: manage_pgpool2
when: "'manage_pgpool2' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: manage_dbserver
when: "'manage_dbserver' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_pemserver
when: "'setup_pemserver' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_pemagent
when: "'setup_pemagent' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_pgbouncer
when: "'setup_pgbouncer' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: manage_pgbouncer
when: "'manage_pgbouncer' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_barmanserver
when: "'setup_barmanserver' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: setup_barman
when: "'setup_barman' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
- role: autotuning
when: "'autotuning' in lookup('edb_devops.edb_postgres.supported_roles', wantlist=True)"
You can customize the above example to install Postgres, EPAS, EFM or PEM or limit what roles you would like to execute.
The following will occur should a password not be provided for the following accounts:
pg_superuser
pg_replication_user
pg_efm_user
pg_pem_agent_user
pg_pem_admin_user
Note:
- The
~/.edb
folder and contained files are secured by assigning the permissions touser
executing the playbook. - A password of 20 characters will be automatically created under:
~/.edb
folder. - The naming convention for the password file is:
<username>_pass
Examples of utilizing the playbooks for installing: Postgres, EnterpriseDB
Postgres Advanced Server, Centos7 or RHEL7 are provided and located within the
playbook-examples
directory.
# To deploy community Postgres version 13 with the user centos
$ ansible-playbook playbook.yml \
-i inventory.yml \
-u centos \
--private-key <key.pem> \
--extra-vars="pg_version=13 pg_type=PG"
# To deploy EPAS version 12 with the user ec2-user
$ ansible-playbook playbook.yml \
-i inventory.yml \
-u ec2-user \
--private-key <key.pem> \
--extra-vars="pg_version=12 pg_type=EPAS repo_username=xxxxx repo_password=xxxxx"
Distribution | 10 | 11 | 12 | 13 |
---|---|---|---|---|
Centos 7 | ✅ | ✅ | ✅ | ✅ |
Red Hat Linux 7 | ✅ | ✅ | ✅ | ✅ |
Centos 8 | ✅ | ✅ | ✅ | ✅ |
Red Hat Linux 8 | ✅ | ✅ | ✅ | ✅ |
Debian | ❌ | ❌ | ❌ | ❌ |
Ubuntu | ❌ | ❌ | ❌ | ❌ |
SLES | ❌ | ❌ | ❌ | ❌ |
Distribution | 10 | 11 | 12 |
---|---|---|---|
Centos 7 | ✅ | ✅ | ✅ |
Red Hat Linux 7 | ✅ | ✅ | ✅ |
Centos 8 | ❌ | ❌ | ✅ |
Red Hat Linux 8 | ❌ | ❌ | ✅ |
Debian | ❌ | ❌ | ❌ |
Ubuntu | ❌ | ❌ | ❌ |
SLES | ❌ | ❌ | ❌ |
- ✅ - Tested and supported
- ❌ - Not tested and not supported
BSD
Author:
- Doug Ortiz
- Julien Tachoires
- Vibhor Kumar
- Collection Name: postgres
- DevOps
- edb-devops@enterprisedb www.enterprisedb.com