diff --git a/README.md b/README.md index 3dc60db..2de1f61 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Role Name ========= -A role that installs a TimeScaleDB instance +A role that installs a TimeScaleDB instance. See Role Variables -------------- @@ -9,7 +9,7 @@ Role Variables The most important variables are listed below: ``` yaml -timescale_db_ubuntu_repo: 'ppa:timescale/timescaledb-ppa' +timescale_db_ubuntu_repo: 'deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main' timescale_db_pkg: 'timescaledb-2-postgresql-{{ psql_version }}' timescale_db_deb_pkgs: '{{ timescale_db_pkg }}' @@ -19,7 +19,7 @@ timescale_db_el_pkgs: timescaledb_configuration_settings: - { name: 'timescaledb.last_tuned', value: "'{{ ansible_date_time.date }}T{{ ansible_date_time.time }}{{ ansible_date_time.tz_offset }}'", set: 'True' } - - { name: 'timescaledb.last_tuned_version', value: "'0.11.0'", set: 'True' } +# - { name: 'timescaledb.last_tuned_version', value: "'0.11.0'", set: 'True' } - { name: 'timescaledb.max_background_workers', value: '{{ ansible_processor_vcpus * 2 }}', set: 'True' } - { name: 'max_worker_processes', value: '{{ (ansible_processor_vcpus * 4) - 1 }}', set: 'True' } - { name: 'max_parallel_workers_per_gather', value: '{{ (ansible_processor_vcpus / 2) | int }}', set: 'True' } diff --git a/defaults/main.yml b/defaults/main.yml index 13379ae..01d03c6 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,15 +1,20 @@ --- -timescale_db_ubuntu_repo: 'ppa:timescale/timescaledb-ppa' +timescale_db_ubuntu_repo_url: 'https://packagecloud.io/timescale/timescaledb/ubuntu' +timescale_db_repo_key_url: "https://packagecloud.io/timescale/timescaledb/gpgkey" +timescale_db_repo_key: "/etc/apt/keyrings/timescaledb.asc" timescale_db_pkg: 'timescaledb-2-postgresql-{{ psql_version }}' -timescale_db_deb_pkgs: '{{ timescale_db_pkg }}' +timescale_db_deb_pkgs: + - '{{ timescale_db_pkg }}' + - timescaledb-tools timescale_db_el_pkgs: - '{{ timescale_db_pkg }}' + - timescaledb-tools - libpq5-devel timescaledb_configuration_settings: - { name: 'timescaledb.last_tuned', value: "'{{ ansible_date_time.date }}T{{ ansible_date_time.time }}{{ ansible_date_time.tz_offset }}'", set: 'True' } - - { name: 'timescaledb.last_tuned_version', value: "'0.11.0'", set: 'True' } +# - { name: 'timescaledb.last_tuned_version', value: "'0.11.0'", set: 'True' } - { name: 'timescaledb.max_background_workers', value: '{{ ansible_processor_vcpus * 2 }}', set: 'True' } - { name: 'max_worker_processes', value: '{{ (ansible_processor_vcpus * 4) - 1 }}', set: 'True' } - { name: 'max_parallel_workers_per_gather', value: '{{ (ansible_processor_vcpus / 2) | int }}', set: 'True' } diff --git a/meta/main.yml b/meta/main.yml index 27caa86..77a1859 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,13 +1,11 @@ galaxy_info: author: Andrea Dell'Amico - description: Systems Architect + description: Role that installs timescaleDB company: ISTI-CNR - - issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning - + namespace: adellam + role_name: timescaledb license: EUPL 1.2+ - - min_ansible_version: 2.8 + min_ansible_version: "2.15" # To view available platforms and versions (or releases), visit: # https://galaxy.ansible.com/api/v1/platforms/ @@ -16,9 +14,11 @@ galaxy_info: - name: Ubuntu versions: - bionic + - focal + - jammy - name: EL versions: - - 7 + - "7" galaxy_tags: - DB diff --git a/tasks/main.yml b/tasks/main.yml index 81cb870..543200d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,7 +1,8 @@ --- -- import_tasks: timescale_db_deb.yml +- name: TimescaleDB on deb distributions + ansible.builtin.import_tasks: timescale_db_deb.yml when: ansible_distribution_file_variety == "Debian" -- import_tasks: timescale_db_el.yml +- name: TimescaleDB on EL derived distributions + ansible.builtin.import_tasks: timescale_db_el.yml when: ansible_distribution_file_variety == "RedHat" - diff --git a/tasks/timescale_db_deb.yml b/tasks/timescale_db_deb.yml index dfaa6b2..9a567b0 100644 --- a/tasks/timescale_db_deb.yml +++ b/tasks/timescale_db_deb.yml @@ -1,35 +1,41 @@ --- -- name: Manage the installation on deb based distributions +- name: timescale_db_deb | Manage the installation on deb based distributions + tags: [postgresql, timescale, timescaledb] block: - - name: Install the Ubuntu PPA - apt_repository: - repo: '{{ timescale_db_ubuntu_repo }}' - update_cache: True + - 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 when: ansible_distribution == "Ubuntu" - - - name: Install the timescale DB package on deb - apt: + - 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 - tags: [ postgresql, timescale, timescaledb ] - -- name: Manage the timescale + postgresql settings +- name: timescale_db_deb | Manage the timescale + postgresql settings + tags: ['postgresql', 'postgres', 'pg_conf', 'timescale', 'timescaledb', 'timescale_conf'] block: - - name: Enable the TimeScaleDB extension - become: True + - name: timescale_db_deb | PostgreSQL settings for TimeScaleDB + become: true become_user: postgres - action: configfile path={{ psql_conf_dir }}/postgresql.conf key=shared_preload_libraries value="'timescaledb'" - notify: Restart postgresql - - - name: TimeScaleDB setting for postgresql - become: True - become_user: postgres - action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}" - with_items: '{{ timescaledb_configuration_settings }}' - when: item.set == 'True' + community.postgresql.postgresql_set: + name: '{{ item.name }}' + value: "{% if item.set %}{{ item.value }}{% else %}default{% endif %}" + loop: '{{ timescaledb_configuration_settings }}' notify: Reload postgresql - - tags: [ 'postgresql', 'postgres', 'pg_conf', 'timescale', 'timescaledb', 'timescale_conf' ] diff --git a/tasks/timescale_db_el.yml b/tasks/timescale_db_el.yml index d05edf1..935fcdd 100644 --- a/tasks/timescale_db_el.yml +++ b/tasks/timescale_db_el.yml @@ -1,32 +1,29 @@ --- -- name: Manage the installation on EL based distributions +- name: timescale_db_el | Manage the installation on EL based distributions + tags: [postgresql, timescale, timescaledb] block: - - name: Install the repository configuration on EL - template: + - name: timescale_db_el | Install the repository configuration on EL + ansible.builtin.template: src: timescale_timescaledb.repo.j2 dest: /etc/yum.repos.d/timescale_timescaledb.repo + owner: root + group: root + mode: "0644" - - name: Install the timescale DB package on EL - yum: + - name: timescale_db_el | Install the timescale DB package on EL + ansible.builtin.yum: pkg: '{{ timescale_db_el_pkgs }}' state: present - tags: [ postgresql, timescale, timescaledb ] - -- name: Manage the timescale + postgresql settings on EL based distributions +- name: timescale_db_el | Manage the timescale + postgresql settings on EL based distributions + tags: ['postgresql', 'postgres', 'pg_conf', 'timescale', 'timescaledb', 'timescale_conf'] block: - - name: Enable the TimeScaleDB extension on EL - become: True - become_user: postgres - action: configfile path={{ psql_el_conf_dir }}/postgresql.conf key=shared_preload_libraries value="'timescaledb'" - notify: Restart postgresql - - name: TimeScaleDB setting for postgresql on EL - become: True + - name: timescale_db_el | TimeScaleDB setting for postgresql on EL + become: true become_user: postgres - action: configfile path={{ psql_el_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}" - with_items: '{{ timescaledb_configuration_settings }}' - when: item.set == 'True' + community.postgresql.postgresql_set: + name: '{{ item.name }}' + value: "{% if item.set %}{{ item.value }}{% else %}default{% endif %}" + loop: '{{ timescaledb_configuration_settings }}' notify: Reload postgresql - - tags: [ 'postgresql', 'postgres', 'pg_conf', 'timescale', 'timescaledb', 'timescale_conf' ]