Introduction
Automating your database (PostgreSQL) with Ansible enables you to achieve Infrastructure as Code (IaC). Using IaC, you're going to be able to automate your workflow, your CI/CD pipelines, for example, and be faster in addressing your critical business demands.
Beginners
Ansible provides various modules to manage PostgreSQL databases, including backup, restore, user provisioning, and more. I'll show you step-by-step how to prepare your Ansible controller to interact with the PostgreSQL infrastructure. This initial configuration is sometimes a roadblock for some PostgreSQL users starting with Ansible.
Installation
- [Install PostgreSQL in Debian-like systems - Ansible modules apt, stat, shell, service](/articles/install-postgresql-in-debian-like-systems-ansible-modules-apt-stat-shell-service)
- [Install PostgreSQL in RedHat-like systems - Ansible modules yum, stat, shell, service](/articles/install-postgresql-in-redhat-like-systems-ansible-modules-yum-stat-shell-service)
Usage
- [Run a SQL Command Query on PostgreSQL - Ansible module postgresql_query](/articles/run-a-sql-command-query-on-postgresql-ansible-module-postgresqlquery)
Backup and Restore
- [Backup a PostgreSQL Database - Ansible module postgresql_db](/articles/backup-a-postgresql-database-ansible-module-postgresqldb)
- [Restore a PostgreSQL Database - Ansible module postgresql_db](/articles/restore-a-postgresql-database-ansible-module-postgresqldb)
Database Management
- [Create a PostgreSQL Database - Ansible module postgresql_db](/articles/create-a-postgresql-database-ansible-module-postgresqldb)
- [Drop a PostgreSQL Database - Ansible module postgresql_db](/articles/drop-a-postgresql-database-ansible-module-postgresqldb)
- [Rename a PostgreSQL Database - Ansible module postgresql_db](/articles/rename-a-postgresql-database-ansible-module-postgresqldb)
Access/User Management
- [Create a PostgreSQL User or Role - Ansible module postgresql_user](/articles/create-a-postgresql-user-or-role-ansible-module-postgresqluser)
- [Allow md5 Connection for a PostgreSQL User or Role - Ansible module postgresql_pg_hba](/articles/allow-md5-connection-for-a-postgresql-user-or-role-ansible-module-postgresqlpghba)
- [Grant Privileges to User or Role on PostgreSQL Database - Ansible module postgresql_privs](/articles/grant-privileges-to-user-or-role-on-postgresql-database-ansible-module-postgresqlprivs)
{{< promote-video-book-PostgreSQL >}}
Conclusion
Now you know how to automate your PostgreSQL database using Ansible Automation technology.