69 lines
2.6 KiB
YAML
69 lines
2.6 KiB
YAML
---
|
|
- name: timescale_db_deb | Manage the installation on deb based distributions
|
|
tags: [postgresql, timescale, timescaledb]
|
|
block:
|
|
- name: timescale_db_deb | Repo key
|
|
ansible.builtin.get_url:
|
|
url: "{{ timescale_db_repo_key_url }}"
|
|
dest: "{{ timescale_db_repo_key }}"
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
force: true
|
|
- name: timescale_db_deb | Install the repository for Ubuntu
|
|
ansible.builtin.deb822_repository:
|
|
name: timescaledb
|
|
types: [deb]
|
|
uris: "{{ timescale_db_ubuntu_repo_url }}"
|
|
components:
|
|
- main
|
|
suites: ["{{ ansible_distribution_release | lower }}"]
|
|
signed_by: "{{ timescale_db_repo_key }}"
|
|
state: present
|
|
enabled: true
|
|
register: timescaledb_repo
|
|
when: ansible_distribution == "Ubuntu"
|
|
- name: timescale_db_deb | Update the apt cache
|
|
ansible.builtin.apt:
|
|
update_cache: yes
|
|
when: timescaledb_repo is changed
|
|
- name: timescale_db_deb | Install the timescale DB package on deb
|
|
ansible.builtin.apt:
|
|
pkg: '{{ timescale_db_deb_pkgs }}'
|
|
state: present
|
|
cache_valid_time: 1800
|
|
|
|
- name: timescale_db_deb | Manage the timescale + postgresql settings
|
|
tags: ['postgresql', 'postgres', 'pg_conf', 'timescale', 'timescaledb', 'timescale_conf']
|
|
block:
|
|
- name: timescale_db_deb | Load the timescaleDB shared library
|
|
become: true
|
|
become_user: postgres
|
|
ansible.builtin.lineinfile:
|
|
path: "{{ psql_conf_dir }}/postgresql.conf"
|
|
regexp: "^#shared_preload_libraries\ ="
|
|
line: "shared_preload_libraries = 'timescaledb'"
|
|
create: false
|
|
state: present
|
|
notify: Restart postgresql
|
|
- name: timescale_db_deb | TimeScaleDB configuration flush handlers
|
|
ansible.builtin.meta: flush_handlers
|
|
- name: timescale_db_deb | PostgreSQL settings for TimeScaleDB
|
|
become: true
|
|
become_user: postgres
|
|
community.postgresql.postgresql_set:
|
|
name: '{{ item.name }}'
|
|
value: "{% if item.set %}{{ item.value }}{% else %}default{% endif %}"
|
|
loop: '{{ timescaledb_configuration_settings }}'
|
|
notify: Reload postgresql
|
|
- name: timescale_db_deb | Some settings must be written into a config file
|
|
become: true
|
|
become_user: postgres
|
|
ansible.builtin.template:
|
|
src: timescaledb.conf.j2
|
|
dest: "{{ psql_conf_dir }}/conf.d/timescaledb.conf"
|
|
mode: "0644"
|
|
notify: Restart postgresql
|
|
- name: timescale_db_deb | TimeScaleDB configuration flush handlers again after the final configuration
|
|
ansible.builtin.meta: flush_handlers
|