This article offers steps for configuring automation for existing resources using available Ansible resources on the EnterpriseDB GitHub repository. This is an open source project and is not officially supported by EDB Support.
Postgres Database and Replication Setup
- EDB Failover Manager (EFM) Setup for Postgres Cluster
- EDB Postgres Enterprise Manager (PEM) Monitoring Server Setup
- Registering a PEM Agent with a PEM Server
- Scaling the DB Cluster
- BART Server
In my previous post, I shared details about the availability of the deployment scripts on EnterpriseDB GitHub. Improving the Postgres deployment experience—by designing and developing automation that makes Postgres deployments in the cloud and on-premises easy—is the idea behind making these Postgres deployment scripts available for everyone on the GitHub Repository.
In response, some of our users requested that we also make the automation available for those who do not want to launch new infrastructure but simply want to leverage the automation on the existing resources (such as a VM or cloud instance already running). This post will outline how a user can do that.
The scripts on GitHub outlined the details for how to create new resources using Terraform scripts. Then, Ansible scripts were used for configuration setup of the Postgres database and tools like EDB Failover Manager (EFM) for high availability, Postgres Enterprise Manager (PEM) for monitoring the Postgres cluster, and EDB Backup and Recovery Tool (BART) for maintaining the backups. Now, separating the deployment and configuration management parts of the scripts allows the user to consume either of the specific scripts based on their requirements and use-case.
Let’s see how the EDB platform’s available Ansible scripts can be used for your existing servers. The default cluster size is a 3-node cluster with one Master and two Standby nodes. We are going to use the same configuration here to show the various examples.
Postgres Database and Replication Setup
If you have the infrastructure ready and want to install/configure the Postgres database, you can execute the following Ansible playbooks available on the GitHub repository and get started. Here are the steps you can follow.
AWS
Go to the module directory DB_Cluster_AWS/config_cluster. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file.
<master_public_ip> ansible_user= ansible_ssh_private_key_file=
<slave1_public_ip> ansible_user= ansible_ssh_private_key_file=
<slave2_public_ip> ansible_user= ansible_ssh_private_key_file=
The hosts file should look like this:
172.0.0.1 ansibler_user=centos ansible_ssh_private_key_file=/User/edb/abc.pem
172.0.0.2 ansibler_user=centos ansible_ssh_private_key_file=/User/edb/abc.pem
172.0.0.3 ansibler_user=centos ansible_ssh_private_key_file=/User/edb/abc.pem
Ansible deployment for setting the Postgres replication
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts setupsr.yml --extra-vars='USER= PASS= EPASDBUSER= PGDBUSER= ip1= ip2= ip3= S3BUCKET= REPLICATION_USER_PASSWORD= DBPASSWORD= REPLICATION_TYPE= DB_ENGINE= MASTER= SLAVE1= SLAVE2='
VMware (vSphere)
Go to the module directory DB_Cluster_VMWARE/config_cluster. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file.
Ansible deployment for setting up the Postgres replication
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts setupsr.yml --extra-vars='USER= PASS= EPASDBUSER= PGDBUSER= ip1= ip2= ip3= REPLICATION_USER_PASSWORD= DBPASSWORD= REPLICATION_TYPE= DB_ENGINE= MASTER= SLAVE1= SLAVE2='
EDB Failover Manager (EFM) Setup for Postgres Cluster
If you have the infrastructure ready and want to set up the EFM tool for automatic failover capability for the existing Postgres cluster, you can run the following Ansible playbooks.
AWS
Go to the module directory EFM_Setup_AWS/config_efm. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file.
Ansible deployment of EFM for 3-node Postgres cluster
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts setupefm.yml --extra-vars='DB_ENGINE= USER= PASS= DBUSER= EFM_USER_PASSWORD= MASTER= SLAVE1= SLAVE2= ip1= ip2= ip3= NOTIFICATION_EMAIL= REGION_NAME= S3BUCKET='
VMware (vSphere)
Go to the module directory EFM_Setup_VMWARE/config_efm. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more details you can refer to the README.md file.
Ansible deployment of EFM for 3-Node Postgres cluster
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts setupefm.yml --extra-vars='DB_ENGINE= USER= PASS= DBUSER= EFM_USER_PASSWORD= MASTER= SLAVE1= SLAVE2= NOTIFICATION_EMAIL='
EDB Postgres Enterprise Manager (PEM) Monitoring Server Setup
If you have the infrastructure ready and want to configure that for a PEM monitoring server, you can run the following Ansible playbooks and configure it.
AWS
Go to the module directory PEM_Server_AWS/config_pem_server. A sample hosts file is present inside this directory. Open the hosts file and add your server details in it.
Ansible deployment for PEM monitoring server
Use the following command to run ansible-playbook. Make sure you are providing extra arguments. For the parameter details, you can refer to the README.md file.
ansible-playbook -i hosts pemserver.yml --extra-vars='USER= PASS= DB_PASSWORD= PEM_IP='
VMware (vSphere)
Go to the module directory PEM_Server_VMWARE/config_pem_server. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it.
Ansible deployment for PEM monitoring server
Use the below command to run ansible-playbook. Make sure you are providing extra arguments. For the parameter details, you can refer to the README.md file.
ansible-playbook -i hosts pemserver.yml --extra-vars='USER= PASS= DB_PASSWORD= PEM_IP='
Registering a PEM Agent with a PEM Server
If you have the infrastructure ready and want to set up a PEM agent, you can run the following Ansible playbooks and configure it.
AWS
Go to the module directory PEM_Agent_AWS/config_pem_agent. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file inside this directory.
Ansible deployment for PEM agent
Use the below command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts installpemagent.yml --extra-vars='DB_ENGINE= USER= PASS= PEM_IP= DBPASSWORD= PEM_WEB_PASSWORD= EPASDBUSER= PGDBUSER='
VMware (vSphere)
Go to the module directory PEM_Agent_VMWARE/config_pem_agent. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more details you can refer to the README.md file inside this directory.
Ansible deployment for PEM agent
Use the below command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts installpemagent.yml --extra-vars='DB_ENGINE= USER= PASS= PEM_IP= DBPASSWORD= PEM_WEB_PASSWORD= EPASDBUSER= PGDBUSER='
Scaling the DB Cluster
If you have the infrastructure ready and want to scale clusters, you can run the following Ansible playbooks and configure it.
AWS
Go to the module directory Expand_DB_Cluster_AWS/scale_cluster. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file inside this directory.
Ansible deployment for scaling existing cluster
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts expandcluster.yml --extra-vars='DB_ENGINE= USER= PASS= PGDBUSER= EPASDBUSER= NEWSLAVE= REPLICATION_USER_PASSWORD= REPLICATION_TYPE= ip1= ip2= ip3= IPPRIVATE= NOTIFICATION_EMAIL= MASTER= SLAVE1= SLAVE2= DBPASSWORD= PEM_IP= PEM_WEB_PASSWORD= S3BUCKET= EFM_USER_PASSWORD= REGION_NAME='
VMware (vSphere)
Go to the module directory Expand_DB_Cluster_VMWARE/scale_cluster. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file inside this directory.
Ansible deployment for scaling existing cluster
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts expandcluster.yml --extra-vars='USER= PASS= PGDBUSER= EPASDBUSER= DB_ENGINE= EFM_USER_PASSWORD= NOTIFICATION_EMAIL= PEM_IP= PEM_WEB_PASSWORD= DBPASSWORD= REPLICATION_USER_PASSWORD= REPLICATION_TYPE= ip1= ip2= ip3= MASTER= SLAVE1= SLAVE2= NEWSLAVE='
BART Server
If you are VM ready and want to configure as BART, here are the steps you can follow to configure it.
AWS
Go to the module directory Bart_AWS/config_bart. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file inside this directory.
Ansible deployment for BART server
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts bartserver.yml --extra-vars='USER= PASS= BART_IP= DB_IP= DB_ENGINE= DB_PASSWORD= DB_USER= RETENTION_PERIOD='
VMware (vSphere)
Go to the module directory Bart_VMWARE/config_bart. A sample hosts file is already present inside this directory. Open the hosts file and add your server details in it. For more information you can refer to the README.md file inside this directory.
Ansible deployment for BART server
Use the following command to run ansible-playbook. Make sure you are providing extra arguments.
ansible-playbook -i hosts bartserver.yml --extra-vars='USER= PASS= BART_IP= DB_IP= DB_ENGINE= DB_PASSWORD= DB_USER= RETENTION_PERIOD='