diff --git a/roles/postgres/tasks/main.yml b/roles/postgres/tasks/main.yml index 922d9d6..c65aacb 100644 --- a/roles/postgres/tasks/main.yml +++ b/roles/postgres/tasks/main.yml @@ -21,16 +21,19 @@ become_user: postgres notify: Restart postgres -- name: Put main configuration files +- name: Put hba configuration files ansible.builtin.copy: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - mode: "{{ item.mode }}" - loop: - - {src: "files/postgresql.conf", dest: "/etc/postgresql/{{ pg_version }}/main/postgresql.conf", mode: "0644"} - - {src: "files/pg_hba.conf", dest: "/etc/postgresql/{{ pg_version }}/main/pg_hba.conf", mode: "0640"} + src: "files/pg_hba.conf" + dest: "/etc/postgresql/{{ pg_version }}/main/pg_hba.conf" + mode: "0640" notify: Restart postgres +- name: Put main configuration files + ansible.builtin.template: + src: "postgresql.conf.j2" + dest: "/etc/postgresql/{{ pg_version }}/main/postgresql.conf" + mode: "0644" + - name: Create backup dir ansible.builtin.file: path: /srv/backup/pgsql diff --git a/roles/postgres/files/postgresql.conf b/roles/postgres/templates/postgresql.conf.j2 similarity index 98% rename from roles/postgres/files/postgresql.conf rename to roles/postgres/templates/postgresql.conf.j2 index 3e03cf9..92e1fcc 100644 --- a/roles/postgres/files/postgresql.conf +++ b/roles/postgres/templates/postgresql.conf.j2 @@ -40,13 +40,13 @@ data_directory = '/srv/postgresql' # use data in another directory # (change requires restart) -hba_file = '/etc/postgresql/13/main/pg_hba.conf' # host-based authentication file +hba_file = '/etc/postgresql/{{ pg_version }}/main/pg_hba.conf' # host-based authentication file # (change requires restart) -ident_file = '/etc/postgresql/13/main/pg_ident.conf' # ident configuration file +ident_file = '/etc/postgresql/{{ pg_version }}/main/pg_ident.conf' # ident configuration file # (change requires restart) # If external_pid_file is not explicitly set, no extra PID file is written. -external_pid_file = '/var/run/postgresql/13-main.pid' # write an extra PID file +external_pid_file = '/var/run/postgresql/{{ pg_version }}-main.pid' # write an extra PID file # (change requires restart) @@ -484,7 +484,7 @@ log_timezone = 'Europe/Paris' # PROCESS TITLE #------------------------------------------------------------------------------ -cluster_name = '13/main' # added to process titles if nonempty +cluster_name = '{{ pg_version }}/main' # added to process titles if nonempty # (change requires restart) #update_process_title = on @@ -500,7 +500,7 @@ cluster_name = '13/main' # added to process titles if nonempty #track_io_timing = off #track_functions = none # none, pl, all #track_activity_query_size = 1024 # (change requires restart) -stats_temp_directory = '/var/run/postgresql/13-main.pg_stat_tmp' +#stats_temp_directory = '/var/run/postgresql/{{ pg_version }}-main.pg_stat_tmp' # - Monitoring -