Skip to content

Commit

Permalink
rename postgres variables to be explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech committed Jul 25, 2024
1 parent b085e5e commit d65a821
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions roles/postgresql/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
postgres_enabled: false
postgres_databases:
- conda-store
pg_data_directory: /opt/conda-store/postgres/data/
pg_user: postgres
pg_version: 14
postgres_data_directory: /opt/conda-store/postgres/data/
postgres_user: postgres
postgres_version: 14

postgres_users:
- username: conda-store
Expand Down
14 changes: 7 additions & 7 deletions roles/postgresql/tasks/postgresql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@

- name: Create the data directory
ansible.builtin.file:
path: "{{ pg_data_directory }}"
owner: "{{ pg_user }}"
group: "{{ pg_user }}"
path: "{{ postgres_data_directory }}"
owner: "{{ postgres_user }}"
group: "{{ postgres_user }}"
mode: "0700"
state: directory
become: true

- name: Initialize the PostgreSQL database
ansible.builtin.command: sudo -u {{ pg_user }} /usr/lib/postgresql/{{ pg_version }}/bin/initdb -D {{ pg_data_directory }}
ansible.builtin.command: sudo -u {{ postgres_user }} /usr/lib/postgresql/{{ postgres_version }}/bin/initdb -D {{ postgres_data_directory }}
args:
creates: "{{ pg_data_directory }}/PG_VERSION"
creates: "{{ postgres_data_directory }}/PG_VERSION"
become: true

- name: Configure PostgreSQL to use the new data directory
ansible.builtin.lineinfile:
path: /etc/postgresql/{{ pg_version }}/main/postgresql.conf
path: /etc/postgresql/{{ postgres_version }}/main/postgresql.conf
regexp: ^#?data_directory =
line: data_directory = '{{ pg_data_directory }}'
line: data_directory = '{{ postgres_data_directory }}'
become: true

- name: Ensure PostgreSQL service is running
Expand Down

0 comments on commit d65a821

Please sign in to comment.