Make this task will work the first time:
- name: Initialize the Database
command: /usr/pgsql-9.6/bin/postgresql96-setup initdb
If run it a second time, will get the error:
fatal: [192.168.0.1]: FAILED! => {"changed": true, "cmd": ["/usr/pgsql-9.6/bin/postgresql96-setup", "initdb"], "delta": "0:00:00.017590", "end": "2019-12-11 06:08:49.999631", "msg": "non-zero return code", "rc": 1, "start": "2019-12-11 06:08:49.982041", "stderr": "", "stderr_lines": [], "stdout": "Data directory is not empty!", "stdout_lines": ["Data directory is not empty!"]}
How to avoid running this task if it already initialized the database on the server?