Skip to main content

Delete PostgreSQL Database

tasks/common/delete_db.yml drops an application's PostgreSQL database through the PostgreSQL maintenance connection. Service-specific cleanup tasks load their connection details from Vault, then supply them to this shared task.

Process​

The task:

  • Validates the supplied database host, port, maintenance password, and database name.
  • Generates a temporary internal-Root-CA client certificate, owned by root, for the PostgreSQL maintenance user.
  • Waits for the database server over verify-full TLS.
  • Drops the application database.
  • Removes the temporary certificate files and clears the task facts after the drop completes.

Input variables​

Each calling service supplies these variables to tasks/common/delete_db.yml:

VariableTypeDescription
cs_common_delete_db_hoststringPostgreSQL host address.
cs_common_delete_db_portintPostgreSQL port.
cs_common_delete_db_maintenance_passwordstringPostgreSQL maintenance user's password.
cs_common_delete_db_databasestringApplication database name.

Prerequisites​

  • The application host must already have the PostgreSQL client installed, see System Patching.