Last active
August 13, 2018 22:00
-
-
Save gravcat/0bebfe665baf3ed3b33ef5de681c237b to your computer and use it in GitHub Desktop.
check for an existing postgres database in a data directory, and do not initdb if found
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assumes you have postgres_data_directory, postgres_user, and postgres_bin_directory set | |
- name: Check for existing database | |
become: yes | |
become_user: postgres | |
stat: | |
path: "{{ postgres_data_directory }}/PG_VERSION" | |
register: pgdata_directory_version | |
- name: Initialize PostgreSQL DB | |
become: yes | |
become_user: "{{ postgres_user }}" | |
command: "{{ postgres_bin_directory }}/initdb -D {{ postgres_data_directory }}" | |
when: not pgdata_directory_version.stat.exists | |
# https://github.com/ansible/ansible/issues/16048#issuecomment-229012509 | |
vars: | |
ansible_ssh_pipelining: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment