From 588d971791f5ff42c340d774c71ea1ba3a16b53e Mon Sep 17 00:00:00 2001 From: Alexander Meindl Date: Mon, 16 Dec 2024 13:58:19 +0100 Subject: [PATCH] use syslog as default logger --- roles/postgresql/defaults/main.yml | 13 +++++++++++-- roles/postgresql/templates/postgresql.j2 | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/roles/postgresql/defaults/main.yml b/roles/postgresql/defaults/main.yml index 2cc3c9f..96de5b7 100644 --- a/roles/postgresql/defaults/main.yml +++ b/roles/postgresql/defaults/main.yml @@ -79,6 +79,10 @@ postgresql_wal_buffers: -1 # see https://docs.timescale.com/self-hosted/latest/install/installation-linux/#install-and-configure-timescaledb-on-postgresql postgresql_with_timescaledb: false +# see https://docs.timescale.com/self-hosted/latest/configuration/timescaledb-config/#timescaledblicense-string +postgresql_timescaledb_license: timescale +# see https://docs.timescale.com/self-hosted/latest/configuration/telemetry/#disabling-telemetry +postgresql_timescaledb_telemetry_level: false # deb https://packagecloud.io/timescale/timescaledb/debian/ bookworm main postgresql_timescaledb_apt_url: https://packagecloud.io/timescale/timescaledb/{{ ansible_distribution | lower }} @@ -111,9 +115,14 @@ postgresql_ssl_cert_file: '/etc/ssl/certs/ssl-cert-snakeoil.pem' postgresql_ssl_crl_file: '' postgresql_ssl_key_file: '/etc/ssl/private/ssl-cert-snakeoil.key' -postgresql_log_destination: stderr +postgresql_log_destination: syslog +postgresql_syslog_facility: local0 +postgresql_syslog_ident: postgres +postgresql_syslog_sequence_numbers: false +postgresql_syslog_split_messages: false + postgresql_log_statement: none -postgresql_log_line_prefix_syslog: 'user=%u,db=%d,app=%aclient=%h ' +postgresql_log_line_prefix_syslog: 'user=%u,db=%d,client=%h,app=%a ' postgresql_log_line_prefix_stderr: '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h ' # disabled, if -1 postgresql_log_min_duration_statement: 2000 diff --git a/roles/postgresql/templates/postgresql.j2 b/roles/postgresql/templates/postgresql.j2 index 51e70e8..02d5c31 100644 --- a/roles/postgresql/templates/postgresql.j2 +++ b/roles/postgresql/templates/postgresql.j2 @@ -484,20 +484,20 @@ log_destination = '{{ postgresql_log_destination }}' # Valid values are combina # or size-driven rotation. Default is # off, meaning append to existing files # in all cases. -{% if postgresql_log_destination == "syslog" %} - -# These are relevant when logging to syslog: -syslog_facility = 'LOCAL0' -syslog_ident = 'postgres' -syslog_sequence_numbers = on -syslog_split_messages = on -{% endif %} # These are relevant when logging to syslog: #syslog_facility = 'LOCAL0' #syslog_ident = 'postgres' #syslog_sequence_numbers = on #syslog_split_messages = on +{% if postgresql_log_destination == "syslog" %} + +# These are relevant when logging to syslog: +syslog_facility = '{{ postgresql_syslog_facility }}' +syslog_ident = {{ postgresql_syslog_ident }} +syslog_sequence_numbers = {{ 'on' if postgresql_syslog_sequence_numbers else 'off' }} +syslog_split_messages = {{ 'on' if postgresql_syslog_split_messages else 'off' }} +{% endif %} # This is only relevant when logging to eventlog (Windows): # (change requires restart) @@ -773,6 +773,13 @@ pg_stat_statements.track = {{ postgresql_pg_stat_statements_track }} {% endif %} #jit_provider = 'llvmjit' # JIT library to use +{% if postgresql_with_timescaledb %} +# see https://docs.timescale.com/self-hosted/latest/configuration/timescaledb-config/#timescaledblicense-string +timescaledb.license = '{{ postgresql_timescaledb_license }}' +# see https://docs.timescale.com/self-hosted/latest/configuration/telemetry/#disabling-telemetry +timescaledb.telemetry_level = {{ 'off' if not postgresql_timescaledb_telemetry_level else postgresql_timescaledb_telemetry_level }} +{% endif %} + # - Other Defaults - #dynamic_library_path = '$libdir'