mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-15 17:20:25 +00:00
Set use_upstream_repo: True
by default
This commit is contained in:
parent
b4edec9f43
commit
84713e8fea
6 changed files with 38 additions and 21 deletions
|
@ -37,8 +37,8 @@ applicable.
|
|||
The state relies on the ``postgres:use_upstream_repo`` Pillar value which could
|
||||
be set as following:
|
||||
|
||||
* ``False`` (default): makes sure that the repository configuration is absent
|
||||
* ``True``: adds the upstream repository to install packages from
|
||||
* ``True`` (default): adds the upstream repository to install packages from
|
||||
* ``False``: makes sure that the repository configuration is absent
|
||||
|
||||
The ``postgres:version`` Pillar controls which version of the PostgreSQL
|
||||
packages should be installed from the upstream repository. Defaults to ``9.5``.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
### Set parameters based on PostgreSQL version supplied with particular distro
|
||||
|
||||
{% set use_upstream_repo = salt['pillar.get']('postgres:use_upstream_repo', false) %}
|
||||
{% set upstream_version = salt['pillar.get']('postgres:version', '9.5') %}
|
||||
{% import_yaml "postgres/repo.yaml" as repo %}
|
||||
|
||||
{% macro debian_codename(name, version, codename=none) %}
|
||||
{#
|
||||
|
@ -17,14 +16,14 @@
|
|||
#}
|
||||
|
||||
{# use upstream version if configured #}
|
||||
{% if use_upstream_repo %}
|
||||
{% set version = upstream_version %}
|
||||
{% if repo.use_upstream_repo %}
|
||||
{% set version = repo.version %}
|
||||
{% endif %}
|
||||
|
||||
{{ codename|default(name, true) }}:
|
||||
# PostgreSQL packages are mostly downloaded from `main` repo component
|
||||
pkg_repo:
|
||||
name: 'deb http://apt.postgresql.org/pub/repos/apt {{ name }}-pgdg main {{ upstream_version }}'
|
||||
name: 'deb http://apt.postgresql.org/pub/repos/apt {{ name }}-pgdg main {{ repo.version }}'
|
||||
pkg: postgresql-{{ version }}
|
||||
pkg_client: postgresql-client-{{ version }}
|
||||
conf_dir: /etc/postgresql/{{ version }}/main
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
# Default lookup dictionary
|
||||
|
||||
postgres:
|
||||
use_upstream_repo: False
|
||||
use_upstream_repo: True
|
||||
version: '9.5'
|
||||
pkg: postgresql
|
||||
pkgs_extra: []
|
||||
pkg_client: postgresql-client
|
||||
|
|
|
@ -1,33 +1,36 @@
|
|||
{% import_yaml "postgres/repo.yaml" as repo %}
|
||||
|
||||
{% if grains['os_family'] == 'RedHat' %}
|
||||
|
||||
### RedHat releases
|
||||
|
||||
{% if salt['pillar.get']('postgres:use_upstream_repo', False) %}
|
||||
{% set version = salt['pillar.get']('postgres:version', '9.5') %}
|
||||
{% set data_dir = '/var/lib/pgsql/' ~ version ~ '/data' %}
|
||||
{% if repo.use_upstream_repo %}
|
||||
|
||||
{% set data_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
||||
|
||||
# PostgreSQL from upstream repository
|
||||
|
||||
default:
|
||||
prepare_cluster:
|
||||
user: postgres
|
||||
command: /usr/pgsql-{{ version }}/bin/initdb -D {{ data_dir }}
|
||||
command: /usr/pgsql-{{ repo.version }}/bin/initdb -D {{ data_dir }}
|
||||
test: test -f {{ data_dir }}/PG_VERSION
|
||||
env: {}
|
||||
'6':
|
||||
prepare_cluster:
|
||||
user: root
|
||||
command: service postgresql-{{ version }} initdb
|
||||
command: service postgresql-{{ repo.version }} initdb
|
||||
test: test -f {{ data_dir }}/PG_VERSION
|
||||
env: {}
|
||||
'7':
|
||||
prepare_cluster:
|
||||
user: root
|
||||
command: /usr/pgsql-{{ version }}/bin/postgresql95-setup initdb
|
||||
command: /usr/pgsql-{{ repo.version }}/bin/postgresql95-setup initdb
|
||||
test: test -f {{ data_dir }}/PG_VERSION
|
||||
env: {}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% set data_dir = '/var/lib/pgsql/data' %}
|
||||
|
||||
# PostgreSQL from OS repositories
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{% set version = salt['pillar.get']('postgres:version', '9.5') %}
|
||||
{% set release = version|replace('.', '') %}
|
||||
{% import_yaml "postgres/repo.yaml" as repo %}
|
||||
|
||||
{% set release = repo.version|replace('.', '') %}
|
||||
|
||||
Arch:
|
||||
conf_dir: /var/lib/postgres/data
|
||||
|
@ -29,17 +30,17 @@ OpenBSD:
|
|||
RedHat:
|
||||
pkg_repo:
|
||||
name: pgdg{{ release }}
|
||||
humanname: PostgreSQL {{ version }} $releasever - $basearch
|
||||
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ version }}/redhat/rhel-$releasever-$basearch'
|
||||
humanname: PostgreSQL {{ repo.version }} $releasever - $basearch
|
||||
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ repo.version }}/redhat/rhel-$releasever-$basearch'
|
||||
gpgcheck: 1
|
||||
gpgkey: 'https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ release }}'
|
||||
|
||||
{% if salt['pillar.get']('postgres:use_upstream_repo', false) %}
|
||||
{% if repo.use_upstream_repo %}
|
||||
|
||||
pkg: postgresql{{ release }}-server
|
||||
pkg_client: postgresql{{ release }}
|
||||
conf_dir: /var/lib/pgsql/{{ version }}/data
|
||||
service: postgresql-{{ version }}
|
||||
conf_dir: /var/lib/pgsql/{{ repo.version }}/data
|
||||
service: postgresql-{{ repo.version }}
|
||||
|
||||
{% else %}
|
||||
|
||||
|
|
11
postgres/repo.yaml
Normal file
11
postgres/repo.yaml
Normal file
|
@ -0,0 +1,11 @@
|
|||
# This file allows to get PostgreSQL version and upstream repo settings
|
||||
# early from Pillar to set correct lookup dictionaty items
|
||||
|
||||
{% import_yaml "postgres/defaults.yaml" as defaults %}
|
||||
|
||||
use_upstream_repo: {{ salt['pillar.get']('postgres:use_upstream_repo',
|
||||
defaults.postgres.use_upstream_repo) }}
|
||||
version: {{ salt['pillar.get']('postgres:version',
|
||||
defaults.postgres.version) }}
|
||||
|
||||
# vim: ft=sls
|
Loading…
Add table
Reference in a new issue