kostiantyn-nemchenko / ansible-role-patroni

:elephant: Ansible Role for Patroni
https://galaxy.ansible.com/kostiantyn-nemchenko/patroni
MIT License
68 stars 44 forks source link

Optimize variables for new Postgres YUM repo structure #60

Closed acehead closed 4 years ago

acehead commented 5 years ago

Hi,

Wanted to upgrade installable version of Postgres to 11. It turned out that for Yum they have changed the approach and now they have single rpm that contains repository for all the packages.

postgresql_yum_repo_url: "https://yum.postgresql.org/{{ patroni_postgresql_version }}/{{ 'fedora' if ansible_distribution|lower == 'fedora' else 'redhat' }}/{{ 'fedora' if ansible_distribution|lower == 'fedora' else 'rhel' }}-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}/{{ postgresql_yum_repo_pkg_name }}"

postgresql_yum_repo_pkg_name: pgdg-redhat-repo-latest.noarch.rpm
postgresql_yum_repo_pkg_version: 11.4-1PGDG.rhel7

patroni_postgresql_packages:
  - { name: "postgresql{{ patroni_postgresql_version|replace('.','') }}-{{ postgresql_yum_repo_pkg_version }}",         state: "present" }
  - { name: "postgresql{{ patroni_postgresql_version|replace('.','') }}-server-{{ postgresql_yum_repo_pkg_version }}",  state: "present" }
  - { name: "postgresql{{ patroni_postgresql_version|replace('.','') }}-contrib-{{ postgresql_yum_repo_pkg_version }}", state: "present" }
  - { name: "postgresql{{ patroni_postgresql_version|replace('.','') }}-devel-{{ postgresql_yum_repo_pkg_version }}",   state: "present" }

I've introduced postgresql_yum_repo_pkg_version variable to specify specific version which will be passed to package names. It would be good to have the same approach built-in and define it on default level so that it is overridable by inventory variables

kostiantyn-nemchenko commented 5 years ago

Hi, Thanks for the input. Will test this approach with multiple Postgres major versions and eventually prepare a PR.