From 22b11fd680b1b7d79a167eb65d8a6aaadc695c93 Mon Sep 17 00:00:00 2001 From: Noel McLoughin Date: Sun, 14 Jan 2018 16:05:12 +0000 Subject: [PATCH] Support for upstream postgresql.org zypp repo after PR review --- pillar.example | 22 ++++++++++------------ postgres/osmap.yaml | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/pillar.example b/pillar.example index 37029ce..871fea8 100644 --- a/pillar.example +++ b/pillar.example @@ -1,19 +1,20 @@ postgres: - # Set True to configure upstream postgresql.org repository for YUM or APT + # UPSTREAM REPO + # Set True to configure upstream postgresql.org repository for YUM/APT/ZYPP use_upstream_repo: False - # Version to install from upstream repository - version: '9.3' + # Version to install from upstream repository (if upstream_repo: True) + version: '9.6' - # These are Debian/Ubuntu specific package names - pkg: 'postgresql-9.3' - pkg_client: 'postgresql-client-9.3' - - # Additional packages to install with PostgreSQL server, - # this should be in a list format + # PACKAGE + # These pillars are typically never required. + # pkg: 'postgresql' + # pkg_client: 'postgresql-client' + # service: postgresql pkgs_extra: - postgresql-contrib - postgresql-plpython + # POSTGRES # Append the lines under this item to your postgresql.conf file. # Pay attention to indent exactly with 4 spaces for all lines. postgresconf: | @@ -48,9 +49,6 @@ postgres: config_backup: ".backup@{{ salt['status.time']('%y-%m-%d_%H:%M:%S') }}" {%- endif %} - # PostgreSQL service name - service: postgresql - {%- if grains['init'] == 'unknown' %} # If Salt is unable to detect init system running in the scope of state run, diff --git a/postgres/osmap.yaml b/postgres/osmap.yaml index bf72717..9a2d17c 100644 --- a/postgres/osmap.yaml +++ b/postgres/osmap.yaml @@ -91,9 +91,43 @@ RedHat: {% endif %} Suse: + pkg_repo: + name: pgdg-sles-{{ release }} + humanname: PostgreSQL {{ repo.version }} $releasever - $basearch + #Using sles-12 upstream repo for opensuse + baseurl: 'https://download.postgresql.org/pub/repos/zypp/{{ repo.version }}/suse/sles-12-$basearch' + key_url: 'https://download.postgresql.org/pub/repos/zypp/{{ repo.version }}/suse/sles-12-$basearch/repodata/repomd.xml.key' + gpgcheck: 1 + gpgautoimport: True + +{% if repo.use_upstream_repo %} + {# Pillars needed are 'use_upstream_repo: True' and 'version: n.n'. #} + {# Avoid setting package names as pillars, as may corrupt postgres. #} + {% set lib_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %} + + pkg: postgresql{{ release }}-server + pkg_client: postgresql{{ release }} + conf_dir: {{ lib_dir }} + service: postgresql-{{ repo.version }} + + #This is postgresql-libs in defaults.yml but upstream is libpqxx + pkg_libpq_dev: libpqxx + pkg_dev: postgresql{{ release }}-devel + pkg_libs: postgresql{{ release }}-libs + + prepare_cluster: + #Full path needed as initdb is NOT 'cross version compatible' binary + command: /usr/pgsql-{{ repo.version }}/bin/initdb --pgdata='{{ lib_dir }}' + test: test -f '{{ lib_dir }}/PG_VERSION' + +{% else %} + pkg: postgresql-server pkg_client: postgresql - pkg_libpq_dev: postgresql + pkg_libpq_dev: libqpxx + pkg_libs: postgresql-libs + +{% endif %} MacOS: service: postgresql @@ -109,5 +143,4 @@ MacOS: user: _postgres group: _postgres - # vim: ft=sls