diff --git a/vars/postgresql.yaml b/vars/postgresql.yaml index 3faa76c..51c4bfa 100644 --- a/vars/postgresql.yaml +++ b/vars/postgresql.yaml @@ -1,5 +1,3 @@ -postgresql_wal_g_install: true - pgbouncer_client_tls_key_file: "{{ pgbouncer_postgresql_ssl_path }}/{{ inventory_hostname }}.key" pgbouncer_client_tls_cert_file: "{{ pgbouncer_postgresql_ssl_path }}/{{ inventory_hostname }}.crt" pgbouncer_systemd_user: "postgres" @@ -12,14 +10,14 @@ pgbouncer_max_db_connections: 10000 pgbouncer_default_pool_size: 1000 postgresql_backup_parameters: - archive_command: "{{ postgresql_archive_command if postgresql_wal_g_backup_enable else 'cd .' }}" - restore_command: "{{ postgresql_restore_command if postgresql_wal_g_backup_enable else 'cd .' }}" + archive_command: "{{ postgresql_archive_command if postgresql_wal_g_install else 'cd .' }}" + restore_command: "{{ postgresql_restore_command if postgresql_wal_g_install else 'cd .' }}" archive_mode: "on" archive_timeout: "1800s" -postgresql_archive_command: "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary ~ ' --config ' ~ wal_g_pg_home_dir ~ '/' ~ wal_g_config_name ~ ' wal-push %p' if postgresql_wal_g_backup_enable else '' }}" +postgresql_archive_command: "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary ~ ' --config ' ~ wal_g_pg_home_dir ~ '/' ~ wal_g_config_name ~ ' wal-push %p' }}" # "restore_command" written to recovery.conf when configuring follower (create replica) -postgresql_restore_command: "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary ~ ' --config ' ~ wal_g_pg_home_dir ~ '/' ~ wal_g_config_name ~ ' wal-fetch %f %p' if postgresql_wal_g_backup_enable else '' }}" +postgresql_restore_command: "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary ~ ' --config ' ~ wal_g_pg_home_dir ~ '/' ~ wal_g_config_name ~ ' wal-fetch %f %p' }}" postgresql_restore_dbs_from_backup_command: "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary ~ ' --config ' ~ postgresql_home_dir ~ '/' ~ postgresql_wal_g_restore_config_name ~ ' backup-fetch ' ~ postgresql_data_dir ~ ' ' ~ postgresql_wal_g_restore_backup_name }}" postgresql_restore_wals_from_backup_command: "{{ 'http_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ 'https_proxy=' ~ wal_g_https_proxy ~ ' ' if wal_g_https_proxy is defined else 'https_proxy=' ~ wal_g_http_proxy ~ ' ' if wal_g_http_proxy is defined else '' }}{{ wal_g_pg_binary ~ ' --config ' ~ postgresql_home_dir ~ '/' ~ postgresql_wal_g_restore_config_name ~ ' wal-fetch %f %p' }}" @@ -27,7 +25,18 @@ postgresql_restore_wals_from_backup_command: "{{ 'http_proxy=' ~ wal_g_http_prox # postgresql_restore_command: "pgbackrest --stanza={{ pgbackrest_stanza }} archive-get %f %p" # restore WAL-s using pgbackrest # postgresql_restore_command: "pg_probackup-{{ pg_probackup_version }} archive-get -B {{ pg_probackup_dir }} --instance {{ pg_probackup_instance }} --wal-file-path=%p --wal-file-name=%f" # restore WAL-s using pg_probackup +# PostgreSQL WAL-G +postgresql_wal_g_install: true + # WAL-G +wal_g_install: "{{ postgresql_wal_g_install }}" wal_g_backup_enable: "{{ postgresql_wal_g_backup_enable }}" +wal_g_pg_binary: "/usr/bin/wal-g-pg" +wal_g_config_name: ".walg.json" +wal_g_restore_config_name: ".walg-restore.json" wal_g_backup_retention_enable: "{{ wal_g_backup_enable }}" wal_g_pg_home_dir: "{{ postgresql_home_dir }}" + +# Monitoring +node_exporter_listen_address: "{{ hostvars[inventory_hostname]['ansible_host'] }}" +postgres_exporter_listen_address: "{{ hostvars[inventory_hostname]['ansible_host'] }}"