From cc30fbb9032c857583e3cca4ff65bb02288220ef Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Sat, 31 Mar 2018 21:56:58 +0100 Subject: [PATCH] Updated alternatives solution --- postgres/client.sls | 3 ++- postgres/dev.sls | 17 +++++++++++++++-- postgres/osfamilymap.yaml | 4 ++++ postgres/server/init.sls | 3 ++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/postgres/client.sls b/postgres/client.sls index 473f3c6..d315ea1 100644 --- a/postgres/client.sls +++ b/postgres/client.sls @@ -27,8 +27,9 @@ postgresql-client-libs: {%- for bin in postgres.client_bins %} {%- set path = salt['file.join'](postgres.bin_dir, bin) %} -{{ bin }}: +postgresql-{{ bin }}-altinstall: alternatives.install: + - name: {{ bin }} - link: {{ salt['file.join']('/usr/bin', bin) }} - path: {{ path }} - priority: {{ postgres.linux.altpriority }} diff --git a/postgres/dev.sls b/postgres/dev.sls index c9f330b..24e7704 100644 --- a/postgres/dev.sls +++ b/postgres/dev.sls @@ -14,10 +14,23 @@ install-postgres-libpq-dev: - name: {{ postgres.pkg_libpq_dev }} {% endif %} -{% endif %} +# Alternatives system. Make devclient binaries available in $PATH + {%- if 'bin_dir' in postgres and postgres.linux.altpriority %} + {%- for bin in postgres.dev_bins %} + {%- set path = salt['file.join'](postgres.bin_dir, bin) %} +postgresql-{{ bin }}-altinstall: + alternatives.install: + - name: {{ bin }} + - link: {{ salt['file.join']('/usr/bin', bin) }} + - path: {{ path }} + - priority: {{ postgres.linux.altpriority }} + - onlyif: test -f {{ path }} -{% if grains.os == 'MacOS' %} + {%- endfor %} + {%- endif %} + +{% elif grains.os == 'MacOS' %} # Darwin maxfiles limits {% if postgres.limits.soft or postgres.limits.hard %} diff --git a/postgres/osfamilymap.yaml b/postgres/osfamilymap.yaml index 6d241ac..786b834 100644 --- a/postgres/osfamilymap.yaml +++ b/postgres/osfamilymap.yaml @@ -56,6 +56,8 @@ RedHat: # directory containing PostgreSQL client executables bin_dir: /usr/pgsql-{{ repo.version }}/bin + dev_bins: + - ecg client_bins: - clusterdb - createdb @@ -129,6 +131,8 @@ Suse: # directory containing PostgreSQL client executables bin_dir: /usr/pgsql-{{ repo.version }}/bin + dev_bins: + - ecg client_bins: - pg_archivecleanup - pg_config diff --git a/postgres/server/init.sls b/postgres/server/init.sls index 6e2b23b..c643e25 100644 --- a/postgres/server/init.sls +++ b/postgres/server/init.sls @@ -40,8 +40,9 @@ postgresql-server: {%- for bin in postgres.server_bins %} {%- set path = salt['file.join'](postgres.bin_dir, bin) %} -{{ bin }}: +postgresql-{{ bin }}-altinstall: alternatives.install: + - name: {{ bin }} - link: {{ salt['file.join']('/usr/bin', bin) }} - path: {{ path }} - priority: {{ postgres.linux.altpriority }}