Automating PostgreSQL operations
With the help of the modules in the community.postgresql
collection, it is possible to automate more database maintenance and operations. Let’s take a closer look.
Managing PostgreSQL remote access
Database servers are accessed by applications on remote nodes and this access needs to be configured appropriately and securely. For a test environment, allow wildcard entries (for example, 0.0.0.0/0
), but this is not a recommended practice for production servers. You need to configure the correct IP address or hostname to allow or restrict access to the database. This operation can be automated using the community.postgresql.postgresql_pg_hba
module, as follows:
Figure 8.30 – Grant user access to database
Managing the pg_hba
entries using Ansible will allow you to handle the entire life cycle of the database and its access.
Next, we will learn how to take automated database backups.