kostiantyn-nemchenko / ansible-role-patroni

:elephant: Ansible Role for Patroni

Home Page:https://galaxy.ansible.com/kostiantyn-nemchenko/patroni

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install patroni from pgdg

wilfriedroset opened this issue · comments

Hello,

Thank you for this role.

I would like to suggest that this role provide a way to install patroni from pgdg repository (or simply replace pip installation).
This would save the work from creating users, directory, service file and so on. You already have this repository installed for both Debian and Red-Hat:

postgresql_apt_repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main"

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 }}"

That way we would be able to leverage pgdg contribution, make this role usable for those working behind a strict firewall where allowing pypi is not possible.

I think it would be doable by removing pip usage and adding patroni to patroni_postgresql_packages:

patroni_postgresql_packages:
- { name: "postgresql-{{ patroni_postgresql_version }}", state: "present" }
- { name: "postgresql-client-{{ patroni_postgresql_version }}", state: "present" }
- { name: "postgresql-contrib-{{ patroni_postgresql_version }}", state: "present" }
- { name: "postgresql-server-dev-{{ patroni_postgresql_version }}", state: "present" }

Let me know what you think about this.
Cheers,
W.

@wilfriedroset Thank you for your interest! This looks like a reasonable suggestion to me. IMO the role should support both methods to not introduce any breaking change for those who already using it. If you would like to contribute - feel free to open a PR. I would be happy to review any input to this project. Otherwise, I will try to add pgdg support as soon as I have enough free time.

Following #83 it became possible to install patroni from pgdg. Example

patroni_bin_dir: /usr/bin
patroni_config_file: "config.yml"
patroni_log_destination: not_stderr
patroni_restapi_listen: "{{ private_ip }}:8008"
patroni_restapi_connect_address: "{{ private_ip }}:8008"

# Don't want to install anything from pip
patroni_system_packages: []
patroni_pip_packages: []

# Patroni is in pgdg repository
patroni_postgresql_packages:
  - {name: "postgresql-{{ patroni_postgresql_version }}", state: "present"}
  - {name: "postgresql-client-{{ patroni_postgresql_version }}", state: "present"}
  - {name: "postgresql-contrib-{{ patroni_postgresql_version }}", state: "present"}
  - {name: "patroni", state: "present"}
  - {name: "python3-consul", state: "present"}
  - {name: "postgresql-{{ patroni_postgresql_version }}-pglogical", state: "present"}
  - {name: "timescaledb-postgresql-{{ patroni_postgresql_version }}", state: "present"}
  - {name: "postgresql-{{ patroni_postgresql_version }}-postgis-3", state: "present"}

With this we could make it a bit more straight forward. What do you think about having two files install-pip.yml, install-package.yml included in https://github.com/kostiantyn-nemchenko/ansible-role-patroni/blob/master/tasks/install.yml according to a flag install_method who can have two value pip or package?

Yeah, making the installation process a bit more straight forward and clear sounds good to me.