From 3be08fc76634520c20d443cddfe4d489650c688f Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik Date: Mon, 17 Aug 2020 14:43:37 +0300 Subject: [PATCH] add stats_temp_directory variables postgresql_stats_temp_directory_path postgresql_stats_temp_directory_size #54 --- roles/patroni/tasks/main.yml | 12 +++++++++--- roles/patroni/templates/patroni.yml.j2 | 4 +++- vars/Debian.yml | 4 ++++ vars/RedHat.yml | 4 ++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/roles/patroni/tasks/main.yml b/roles/patroni/tasks/main.yml index 0907e15dc..e53b49150 100644 --- a/roles/patroni/tasks/main.yml +++ b/roles/patroni/tasks/main.yml @@ -313,18 +313,24 @@ - name: Prepare PostgreSQL | create statistics directory (if not already exists) file: - path: /var/lib/pgsql_stats_tmp + path: "{{ postgresql_stats_temp_directory_path }}" state: directory mode: 01777 + when: + - postgresql_stats_temp_directory_path is defined + - postgresql_stats_temp_directory_path != 'none' tags: patroni, pgsql_stats_tmp - name: Prepare PostgreSQL | mount the statistics directory in memory (tmpfs) mount: - path: /var/lib/pgsql_stats_tmp + path: "{{ postgresql_stats_temp_directory_path }}" src: tmpfs fstype: tmpfs - opts: "size=1024m,uid=postgres,gid=postgres" + opts: "size={{ postgresql_stats_temp_directory_size }},uid=postgres,gid=postgres" state: mounted + when: + - postgresql_stats_temp_directory_path is defined + - postgresql_stats_temp_directory_path != 'none' tags: patroni, pgsql_stats_tmp - name: Prepare PostgreSQL | make sure the postgresql log directory "{{ postgresql_log_dir }}" exists diff --git a/roles/patroni/templates/patroni.yml.j2 b/roles/patroni/templates/patroni.yml.j2 index e7bc479f6..0b0735dcb 100644 --- a/roles/patroni/templates/patroni.yml.j2 +++ b/roles/patroni/templates/patroni.yml.j2 @@ -97,7 +97,9 @@ postgresql: # password: rewind_password parameters: unix_socket_directories: {{ postgresql_unix_socket_dir }} - stats_temp_directory: /var/lib/pgsql_stats_tmp +{% if postgresql_stats_temp_directory_path is defined and postgresql_stats_temp_directory_path != 'none' %} + stats_temp_directory: {{ postgresql_stats_temp_directory_path }} +{% endif %} remove_data_directory_on_rewind_failure: {{ patroni_remove_data_directory_on_rewind_failure |string |d(false, true) |lower }} remove_data_directory_on_diverged_timelines: {{ patroni_remove_data_directory_on_diverged_timelines |string |d(false, true) |lower }} diff --git a/vars/Debian.yml b/vars/Debian.yml index 9178926a4..7b36d4871 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -11,6 +11,10 @@ postgresql_unix_socket_dir: "/var/run/postgresql" postgresql_home_dir: "/var/lib/postgresql" postgresql_pgpass: "{{ postgresql_home_dir }}/.pgpass" +# stats_temp_directory (mount the statistics directory in tmpfs) +postgresql_stats_temp_directory_path: "/var/lib/pgsql_stats_tmp" # or 'none' +postgresql_stats_temp_directory_size: "1024m" + postgresql_version_terse: "{{ postgresql_version | replace('.', '') }}" # Repository diff --git a/vars/RedHat.yml b/vars/RedHat.yml index ee8df3fb4..cd43bc354 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -10,6 +10,10 @@ postgresql_unix_socket_dir: "/var/run/postgresql" postgresql_home_dir: "/var/lib/pgsql" postgresql_pgpass: "{{ postgresql_home_dir }}/.pgpass" +# stats_temp_directory (mount the statistics directory in tmpfs) +postgresql_stats_temp_directory_path: "/var/lib/pgsql_stats_tmp" # or 'none' +postgresql_stats_temp_directory_size: "1024m" + postgresql_version_terse: "{{ postgresql_version | replace('.', '') }}" # Repository