Initial
This commit is contained in:
.gitignoreReadme.mdhostsrequirements.txtsetup.yaml
roles
geerlingguy.postgresql
.ansible-lint
.github
.gitignore.yamllintLICENSEREADME.mddefaults
handlers
meta
molecule
default
tasks
configure.ymldatabases.ymlinitialize.ymlmain.ymlsetup-Archlinux.ymlsetup-Debian.ymlsetup-RedHat.ymlusers.ymlusers_props.ymlvariables.yml
templates
vars
nginx
nginxinc.nginx_unit
.ansible-lint
.github
.gitignore.yamllintCHANGELOG.mdCODE_OF_CONDUCT.mdCONTRIBUTING.mdLICENSEREADME.mddefaults
files
handlers
meta
molecule
tasks
templates
vars
python3
tasks
software
tasks
37
roles/geerlingguy.postgresql/tasks/initialize.yml
Normal file
37
roles/geerlingguy.postgresql/tasks/initialize.yml
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
- name: Set PostgreSQL environment variables.
|
||||
template:
|
||||
src: postgres.sh.j2
|
||||
dest: /etc/profile.d/postgres.sh
|
||||
mode: 0644
|
||||
notify: restart postgresql
|
||||
|
||||
- name: Ensure PostgreSQL data directory exists.
|
||||
file:
|
||||
path: "{{ postgresql_data_dir }}"
|
||||
owner: "{{ postgresql_user }}"
|
||||
group: "{{ postgresql_group }}"
|
||||
state: directory
|
||||
mode: 0700
|
||||
|
||||
- name: Check if PostgreSQL database is initialized.
|
||||
stat:
|
||||
path: "{{ postgresql_data_dir }}/PG_VERSION"
|
||||
register: pgdata_dir_version
|
||||
|
||||
- name: Ensure PostgreSQL database is initialized.
|
||||
command: "{{ postgresql_bin_path }}/initdb -D {{ postgresql_data_dir }}"
|
||||
when: not pgdata_dir_version.stat.exists
|
||||
become: true
|
||||
become_user: "{{ postgresql_user }}"
|
||||
# See: https://github.com/ansible/ansible/issues/16048#issuecomment-229012509
|
||||
vars:
|
||||
ansible_ssh_pipelining: true
|
||||
|
||||
- name: Ensure PostgreSQL log directory exists.
|
||||
file:
|
||||
path: "{{ postgresql_effective_log_dir }}"
|
||||
owner: "{{ postgresql_user }}"
|
||||
group: "{{ postgresql_group }}"
|
||||
state: directory
|
||||
mode: 0700
|
Reference in New Issue
Block a user