-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
# Extension Auto-Setup: repository | ||
|
||
# TimescaleDB (if 'enable_timescale' is 'true') | ||
- block: | ||
# Debian based | ||
- name: Add TimescaleDB repository apt-key | ||
ansible.builtin.apt_key: | ||
url: "https://packagecloud.io/timescale/timescaledb/gpgkey" | ||
state: present | ||
when: ansible_os_family == "Debian" | ||
|
||
- name: Add TimescaleDB repository | ||
ansible.builtin.apt_repository: | ||
repo: "deb https://packagecloud.io/timescale/timescaledb/{{ ansible_distribution | lower }}/ {{ ansible_distribution_release }} main" | ||
state: present | ||
update_cache: true | ||
when: ansible_os_family == "Debian" | ||
|
||
# RedHat based | ||
- name: Add TimescaleDB repository | ||
ansible.builtin.yum_repository: | ||
name: "timescale_timescaledb" | ||
description: "timescaledb repo" | ||
baseurl: "https://packagecloud.io/timescale/timescaledb/el/{{ ansible_distribution_major_version }}/x86_64" | ||
gpgkey: "https://packagecloud.io/timescale/timescaledb/gpgkey" | ||
gpgcheck: "no" | ||
when: ansible_os_family == "RedHat" | ||
environment: "{{ proxy_env | default({}) }}" | ||
when: | ||
- installation_method == "repo" | ||
- (enable_timescale | default(false)| bool) or (enable_timescaledb | default(false)| bool) | ||
tags: add_repo, timescaledb, timescale | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,49 @@ | ||
--- | ||
|
||
# TimescaleDB (if enable_timescale is defined) | ||
- block: | ||
- name: TimescaleDB | Checking PostgreSQL version | ||
run_once: true | ||
ansible.builtin.fail: | ||
msg: | ||
- "The current PostgreSQL version ({{ postgresql_version }}) is not supported by the TimescaleDB." | ||
- "PostgreSQL version must be {{ timescale_minimal_pg_version }} or higher." | ||
when: postgresql_version|string is version(timescale_minimal_pg_version|string, '<') | ||
# TimescaleDB pre-check (if 'enable_timescale' is 'true') | ||
- name: TimescaleDB | Checking PostgreSQL version | ||
run_once: true | ||
ansible.builtin.fail: | ||
msg: | ||
- "The current PostgreSQL version ({{ postgresql_version }}) is not supported by the TimescaleDB." | ||
- "PostgreSQL version must be {{ timescale_minimal_pg_version }} or higher." | ||
when: postgresql_version|string is version(timescale_minimal_pg_version|string, '<') | ||
|
||
- name: TimescaleDB | Ensure 'timescaledb' is in 'shared_preload_libraries' | ||
ansible.builtin.set_fact: | ||
# This complex line does several things: | ||
# 1. It takes the current list of PostgreSQL parameters, | ||
# 2. Removes any item where the option is 'shared_preload_libraries', | ||
# 3. Then appends a new 'shared_preload_libraries' item at the end. | ||
# The new value of this item is based on whether 'timescaledb' is already present in the old value. | ||
# If it is not present, it appends ',timescaledb' to the old value. Otherwise, it leaves the value unchanged. | ||
postgresql_parameters: >- | ||
{{ postgresql_parameters | rejectattr('option', 'equalto', 'shared_preload_libraries') | list | ||
+ [{'option': 'shared_preload_libraries', 'value': new_value}] }} | ||
vars: | ||
# Find the last item in postgresql_parameters where the option is 'shared_preload_libraries' | ||
shared_preload_libraries_item: >- | ||
{{ | ||
postgresql_parameters | ||
| selectattr('option', 'equalto', 'shared_preload_libraries') | ||
| list | last | default({'value': ''}) | ||
}} | ||
# Determine the new value based on whether 'timescaledb' is already present | ||
new_value: >- | ||
{{ | ||
(shared_preload_libraries_item.value ~ (',' if shared_preload_libraries_item.value else '') | ||
if 'timescaledb' not in shared_preload_libraries_item.value.split(',') else shared_preload_libraries_item.value) | ||
~ ('timescaledb' if 'timescaledb' not in shared_preload_libraries_item.value.split(',') else '') | ||
}} | ||
when: (enable_timescale | default(false)| bool) or (enable_timescaledb | default(false)| bool) | ||
tags: timescaledb, timescale | ||
# Extension Auto-Setup: shared_preload_libraries | ||
- name: Ensure extensions are in 'shared_preload_libraries' | ||
run_once: true | ||
ansible.builtin.set_fact: | ||
# This complex line does several things: | ||
# 1. It takes the current list of PostgreSQL parameters, | ||
# 2. Removes any item where the option is 'shared_preload_libraries', | ||
# 3. Then appends a new 'shared_preload_libraries' item at the end. | ||
# The new value of this item is based on whether extension is already present in the old value. | ||
# If it is not present, it appends ',<extension_name>' to the old value. Otherwise, it leaves the value unchanged. | ||
postgresql_parameters: >- | ||
{{ postgresql_parameters | rejectattr('option', 'equalto', 'shared_preload_libraries') | list | ||
+ [{'option': 'shared_preload_libraries', 'value': new_value}] }} | ||
vars: | ||
# Find the last item in postgresql_parameters where the option is 'shared_preload_libraries' | ||
shared_preload_libraries_item: >- | ||
{{ | ||
postgresql_parameters | ||
| selectattr('option', 'equalto', 'shared_preload_libraries') | ||
| list | last | default({'value': ''}) | ||
}} | ||
# Determine the new value based on whether the extension is already present | ||
new_value: >- | ||
{{ | ||
(shared_preload_libraries_item.value ~ (',' if shared_preload_libraries_item.value else '') | ||
if item.extension not in shared_preload_libraries_item.value.split(',') else shared_preload_libraries_item.value) | ||
~ (item.extension if item.extension not in shared_preload_libraries_item.value.split(',') else '') | ||
}} | ||
loop: | ||
- { extension: "timescaledb", enabled: (enable_timescale | default(false)| bool) or (enable_timescaledb | default(false)| bool) } | ||
- { extension: "pg_cron", enabled: enable_pg_cron | default(false)| bool } | ||
loop_control: | ||
loop_var: item | ||
label: "{{ item.extension }}" | ||
when: item.enabled | ||
tags: [timescaledb, timescale, pg_cron] | ||
|
||
... |