Use ansible initialize postgresql multiple times

Check to see if the file/directory created by initdb is there first and if not, initdb.

https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html


Q: "stdout: Data directory is not empty!"

A: 18.2. Creating a Database Cluster says:

initdb will refuse to run if the data directory exists and already contains files; this is to prevent accidentally overwriting an existing installation.

To make the command idempotent use the parameter creates, e.g.

    - name: Initialize the Database
      command: /usr/pgsql-9.6/bin/postgresql96-setup initdb
      args:
        creates: /usr/local/pgsql/data