Ansible playbook to create a database and tables on an Azure postgres database server.

Grace Jr., John (Jay) 1 Reputation point
2022-03-01T21:42:51.11+00:00

How do I create an Ansible playbook to connect to and Azure postgres server, then create a database and table.

The server already exists and I know what resource group it's in. I've looked at the connection string and tested my connection with "psql -h <ip address> postgres <username>@db-ansible-postgres" and that works fine.

I've already tested using ansible to connect to a local database and that's working too it's just the remote azure stuff that's throwing me for a loop.

I'll be looking for tutorials on the internet until / unless I get a reponse here.

Thanks in advance.

Azure Database for PostgreSQL
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,631 Reputation points
    2022-03-02T06:55:14.35+00:00

    Hi @Grace Jr., John (Jay) , welcome to Microsoft Q&A forum.

    It seems you want to manage Azure Postgres Server using Ansible Playbook.

    We can refer to below article (this is specific to Azure MySQL but can be used in same way for Azure PostgreSQL except code change which is mentioned below this link) :

    Tutorial: Configure databases in Azure Database for MySQL using Ansible

    And then we can use below code from below link to create server/database:

    postgresql_create.yml

    More details on below link:

    Manage PostgreSQL Server instance

    Please let us know if this helps or we can discuss further on the same.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.