---
- name: Debian or Ubuntu
  block:
  - name: Get the signing key for the postgresql.org repository
    apt_key: url=https://www.postgresql.org/media/keys/ACCC4CF8.asc state=present

  - name: Setup the postgresql.org repository
    apt_repository: repo='deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_lsb.codename }}-pgdg main' update_cache=yes

  when:
    - pg_use_postgresql_org_repo
    - ansible_distribution_file_variety == "Debian"
  tags: [ 'postgresql', 'postgresql_repo' ]

- name: EL
  block:
  - name: Install the pgsql pgdg repository
    yum: name={{ psql_el_pgdg_repo_url }} state={{ psql_pkg_state }}

  when:
    - pg_use_postgresql_org_repo
    - ansible_distribution_file_variety == "RedHat"
  tags: [ 'postgresql', 'postgresql_repo' ]