Skip to content

Commit

Permalink
change postgres data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech committed Jul 24, 2024
1 parent 1bdf512 commit b21dc7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions roles/postgresql/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
postgres_enabled: false
postgres_databases:
- conda-store
pg_data_directory: /opt/conda-store/postgres/data/
pguser: conda-store
pg_version: 14

postgres_users:
- username: conda-store
Expand Down
19 changes: 19 additions & 0 deletions roles/postgresql/tasks/postgresql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@
state: latest
cache_valid_time: 3600

- name: Create the data directory

Check failure on line 13 in roles/postgresql/tasks/postgresql.yaml

View workflow job for this annotation

GitHub Actions / Ansible Lint

fqcn[action-core]

Use FQCN for builtin module actions (file).
file:
path: "{{ pg_data_directory }}"
owner: "{{ pg_user }}"
group: "{{ pg_user }}"
mode: '0700'
state: directory

- name: Initialize the PostgreSQL database

Check failure on line 21 in roles/postgresql/tasks/postgresql.yaml

View workflow job for this annotation

GitHub Actions / Ansible Lint

fqcn[action-core]

Use FQCN for builtin module actions (command).
command: "sudo -u {{ pg_user }} /usr/lib/postgresql/{{ pg_version }}/bin/initdb -D {{ pg_data_directory }}"
args:
creates: "{{ pg_data_directory }}/PG_VERSION"

- name: Configure PostgreSQL to use the new data directory

Check failure on line 26 in roles/postgresql/tasks/postgresql.yaml

View workflow job for this annotation

GitHub Actions / Ansible Lint

fqcn[action-core]

Use FQCN for builtin module actions (lineinfile).
lineinfile:
path: /etc/postgresql/{{ pg_version }}/main/postgresql.conf
regexp: '^#?data_directory ='
line: "data_directory = '{{ pg_data_directory }}'"

- name: Ensure PostgreSQL service is running
ansible.builtin.systemd:
name: postgresql
Expand Down

0 comments on commit b21dc7e

Please sign in to comment.