问题原文
原帖链接 · rawmain · CC BY-SA 4.0
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?
已采纳解答
原帖链接 · dmourati · CC BY-SA 4.0
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
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
