add timescale installation

This commit is contained in:
Attilio Greco 2022-05-24 18:51:03 +02:00
parent 09a6d5a3e1
commit 12b319171a
7 changed files with 91 additions and 21 deletions

View File

@ -4,17 +4,19 @@ postgres_repo: "https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_
postgres_version: 13
postgis_install: true
postgis_version: 31
postgis_version_pakage_name: postgis{{postgis_version}}_{{postgres_version}}
pg_config_listen_addresses: localhost
pg_config_port: 5432
pg_config_max_connections: 1024
pg_config_shared_buffers: 2GB
pg_config_shared_buffers: 128MB
pg_config_temp_buffers: 8MB
pg_config_work_mem: 4MB
pg_config_max_wal_size: 1GB
pg_config_min_wal_size: 4G
pg_config_min_wal_size: 256MB
pg_config_log_filename: postgresql-%Y-%m-%d_%H%M%S.log
pg_config_timezone: "Europe/Rome"
pg_config_row: ""
pg_config_shared_preload_libraries: []
# pg_config_row: |
# max_connections = 200
# effective_cache_size = 6GB
@ -31,7 +33,9 @@ pg_config_row: ""
# max_parallel_workers_per_gather = 1
# max_parallel_workers = 2
# max_parallel_maintenance_workers = 1
additional_extension:
# - postgis
- timescale
pg_hba_user_options:
- contype: host
users: all

View File

@ -1,7 +1,18 @@
- name: Connection Wait
hosts: all
become: true
gather_facts: no
tasks:
- name: Wait 60 seconds, but only start checking after 15 seconds
wait_for_connection:
delay: 15
timeout: 60
- name: prepare
hosts: all
become: true
tasks:
- name: prepare | install python3-pip
dnf:
name:

View File

@ -0,0 +1,16 @@
- name: postgres | install | extension | postgis | add powertools repository
yum_repository:
name: powertools
description: Rocky Linux $releasever - PowerTools
file: external_repos
mirrorlist: https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=PowerTools-$releasever
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
enabled: yes
- name: postgres | install | extension | postgis | enable powertools and install "{{postgis_version_pakage_name}}"
dnf:
enablerepo: powertools
name:
- "{{postgis_version_pakage_name}}"
state: present
when: postgis_install

View File

@ -0,0 +1,13 @@
- name: postgres | install | extension | timescale | add timescale repo
ansible.builtin.template:
src: installation/timescale.repo.j2
dest: /etc/yum.repos.d/timescale_timescaledb.repo
- name: postgres | install | install postgresql
dnf:
name:
- timescaledb-2-postgresql-{{postgres_version}}
state: present
notify:
- restart postgreql

View File

@ -1,7 +1,32 @@
---
- name: Distribution
debug:
msg: "{{ ansible_distribution }}"
- name: Distribution version
debug:
msg: "{{ ansible_distribution_version}}"
- name: Distribution major version
debug:
msg: "{{ ansible_distribution_major_version }}"
- name: postgres | install | postgres pre-install show shared_preload_libraries list
debug:
msg: "{{ pg_config_shared_preload_libraries + ['timescaledb'] }}"
- name: postgres | install | timescale pre-install
set_fact:
pg_config_shared_preload_libraries: "{{ pg_config_shared_preload_libraries + ['timescaledb'] }}"
when: '"timescale" in additional_extension'
- name: postgres | install | postgres pre-install show shared_preload_libraries list
debug:
msg: "{{ pg_config_shared_preload_libraries }}"
- name: postgres | install | install postgres repo
dnf:
name: 'https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm'
name: "https://download.postgresql.org/pub/repos/yum/reporpms/EL-{{ ansible_distribution_major_version }}-x86_64/pgdg-redhat-repo-latest.noarch.rpm"
state: present
disable_gpg_check: yes
@ -23,19 +48,7 @@
name: epel-release
state: present
- name: postgres | install | enabled repo powertools
yum_repository:
name: powertools
description: Rocky Linux $releasever - PowerTools
file: external_repos
mirrorlist: https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=PowerTools-$releasever
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rockyofficial
enabled: yes
- name: postgres | install | install postgis
dnf:
enablerepo: powertools
name:
- postgis31_13
state: present
when: postgis_install
- name: postgres | install | install custom extension
include_tasks: "tasks/extension/{{ item }}.yaml"
with_items: "{{ additional_extension }}"
# when: additional_extension

View File

@ -0,0 +1,10 @@
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/{{ ansible_distribution_major_version }}/$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

View File

@ -710,8 +710,11 @@ lc_time = 'en_US.UTF-8' # locale for time formatting
default_text_search_config = 'pg_catalog.english'
# - Shared Library Preloading -
{% if pg_config_shared_preload_libraries %}
shared_preload_libraries = '{{ pg_config_shared_preload_libraries | join(',') }}'
{% else %}
#shared_preload_libraries = '' # (change requires restart)
{% endif %}
#local_preload_libraries = ''
#session_preload_libraries = ''
#jit_provider = 'llvmjit' # JIT library to use