geerlingguy / ansible-role-postgresql

Ansible Role - PostgreSQL
https://galaxy.ansible.com/geerlingguy/postgresql/
MIT License
572 stars 389 forks source link

versionned packages in vars #260

Open EmptyByte opened 5 months ago

EmptyByte commented 5 months ago

Nice role! Should replace the official RHEL system_role for PostgreSQL imo (have a look at it).

For packages vars I would suggest :

__postgresql_packages: >-
  {{
    ['@postgresql:' ~ postgresql_version ~ '/server', 'postgresql-contrib'] 
    if postgresql_version != '13' 
    else ['postgresql-server', 'postgresql-contrib']
  }}

and then you can define postgresql_version in defaults but this means validating if each version exists

EmptyByte commented 5 months ago
distribution_postgresql_support_map:
  redhat8: [10, 12, 13, 15, 16]
  redhat9: [13, 15, 16]
- name: Check if PostgreSQL version is supported on distribution
  ansible.builtin.assert:
    that: postgresql_version | int in distribution_postgresql_support_map[ansible_facts['distribution'] | lower + ansible_facts['distribution_major_version']]
    success_msg: "PostgreSQL version {{ postgresql_version }} is supported on {{ ansible_facts['distribution'] | lower }} {{ ansible_facts['distribution_major_version'] }}"
    fail_msg: "PostgreSQL version {{ postgresql_version }} is not supported on {{ ansible_facts['distribution'] | lower }} {{ ansible_facts['distribution_major_version'] }}"
    quiet: false
github-actions[bot] commented 1 month ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.