diff --git a/roles/postgresql/defaults/main.yml b/roles/postgresql/defaults/main.yml index 9ae2fc9..9b6e994 100644 --- a/roles/postgresql/defaults/main.yml +++ b/roles/postgresql/defaults/main.yml @@ -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 diff --git a/roles/postgresql/tasks/postgresql.yaml b/roles/postgresql/tasks/postgresql.yaml index 1523015..5e4abce 100644 --- a/roles/postgresql/tasks/postgresql.yaml +++ b/roles/postgresql/tasks/postgresql.yaml @@ -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