galaxyproject / ansible-postgresql

An Ansible role for managing a PostgreSQL server
https://galaxy.ansible.com/galaxyproject/postgresql
122 stars 58 forks source link

Check pgdg repository package task for RHEL based distros should check pgdg-redhat-repo package #21

Closed dracic closed 4 years ago

dracic commented 5 years ago

As of 15 April 2019, there is only one repository RPM per distro, and it includes repository information for all available PostgreSQL releases.

bgruening commented 5 years ago

Thanks @dracic! xref: https://yum.postgresql.org/repopackages.php

dracic commented 5 years ago

There is one issue more. When you install pgdg-redhat-repo, all pg version repos are enabled by default. I don't find this to be elegant solution, and think only pg version defined by postgresql_version variable should be enabled. So I did localy this workaround:

- name: Disable all pgdg repos (RedHat)
  shell: yum-config-manager --disable pgdg\*
  when: __postgresql_repo_pkg_installed_result is failed

- name: Enable appropriate pgdg repo (RedHat)
  ini_file:
    path: /etc/yum.repos.d/pgdg-redhat-all.repo
    section: pgdg{{ postgresql_version }}
    option: enabled
    value: '1' 

I'm in process of learning Ansible, so I'm not sure if this is the most elegant way to do this. If you think this is ok I will push one more commit to this PR.

Best regards Davor

natefoo commented 4 years ago

Thanks @dracic! I think there's a way to do the second part with yum_repository that'd be a bit cleaner, so I'm looking in to that.