mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 09:40:26 +00:00
Merge branch 'master' into alternatives
This commit is contained in:
commit
9e6adde7b5
6 changed files with 57 additions and 25 deletions
|
@ -1,23 +1,25 @@
|
||||||
postgres:
|
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
|
use_upstream_repo: False
|
||||||
# Version to install from upstream repository
|
# Version to install from upstream repository (if upstream_repo: True)
|
||||||
version: '9.3'
|
version: '9.6'
|
||||||
|
|
||||||
# These are Debian/Ubuntu specific package names
|
# PACKAGE
|
||||||
pkg: 'postgresql-9.3'
|
# These pillars are typically never required.
|
||||||
pkg_client: 'postgresql-client-9.3'
|
# pkg: 'postgresql'
|
||||||
|
# pkg_client: 'postgresql-client'
|
||||||
# Additional packages to install with PostgreSQL server,
|
# service: postgresql
|
||||||
# this should be in a list format
|
|
||||||
pkgs_extra:
|
pkgs_extra:
|
||||||
- postgresql-contrib
|
- postgresql-contrib
|
||||||
- postgresql-plpython
|
- postgresql-plpython
|
||||||
|
|
||||||
|
|
||||||
#'Alternatives system' priority incremental. 0 disables feature.
|
#'Alternatives system' priority incremental. 0 disables feature.
|
||||||
linux:
|
linux:
|
||||||
altpriority: 30
|
altpriority: 30
|
||||||
|
|
||||||
|
# POSTGRES
|
||||||
# Append the lines under this item to your postgresql.conf file.
|
# Append the lines under this item to your postgresql.conf file.
|
||||||
# Pay attention to indent exactly with 4 spaces for all lines.
|
# Pay attention to indent exactly with 4 spaces for all lines.
|
||||||
postgresconf: |
|
postgresconf: |
|
||||||
|
@ -52,9 +54,6 @@ postgres:
|
||||||
config_backup: ".backup@{{ salt['status.time']('%y-%m-%d_%H:%M:%S') }}"
|
config_backup: ".backup@{{ salt['status.time']('%y-%m-%d_%H:%M:%S') }}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
# PostgreSQL service name
|
|
||||||
service: postgresql
|
|
||||||
|
|
||||||
{%- if grains['init'] == 'unknown' %}
|
{%- if grains['init'] == 'unknown' %}
|
||||||
|
|
||||||
# If Salt is unable to detect init system running in the scope of state run,
|
# If Salt is unable to detect init system running in the scope of state run,
|
||||||
|
|
|
@ -16,7 +16,7 @@ postgres:
|
||||||
command: initdb --pgdata=/var/lib/pgsql/data
|
command: initdb --pgdata=/var/lib/pgsql/data
|
||||||
test: test -f /var/lib/pgsql/data/PG_VERSION
|
test: test -f /var/lib/pgsql/data/PG_VERSION
|
||||||
user: postgres
|
user: postgres
|
||||||
env: {}
|
env: []
|
||||||
|
|
||||||
conf_dir: /var/lib/pgsql/data
|
conf_dir: /var/lib/pgsql/data
|
||||||
postgresconf: ""
|
postgresconf: ""
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
{{ state }}-{{ name }}:
|
{{ state }}-{{ name }}:
|
||||||
{{ state }}.{{ ensure|default('present') }}:
|
{{ state }}.{{ ensure|default('present') }}:
|
||||||
{{- format_kwargs(kwarg) }}
|
{{- format_kwargs(kwarg) }}
|
||||||
|
- onchanges:
|
||||||
|
- test: postgres-reload-modules
|
||||||
|
|
||||||
{%- endmacro %}
|
{%- endmacro %}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ include:
|
||||||
# Ensure that Salt is able to use postgres modules
|
# Ensure that Salt is able to use postgres modules
|
||||||
|
|
||||||
postgres-reload-modules:
|
postgres-reload-modules:
|
||||||
test.nop:
|
test.succeed_with_changes:
|
||||||
- reload_modules: True
|
- reload_modules: True
|
||||||
|
|
||||||
# User states
|
# User states
|
||||||
|
@ -26,8 +26,6 @@ postgres-reload-modules:
|
||||||
{%- for name, user in postgres.users|dictsort() %}
|
{%- for name, user in postgres.users|dictsort() %}
|
||||||
|
|
||||||
{{ format_state(name, 'postgres_user', user) }}
|
{{ format_state(name, 'postgres_user', user) }}
|
||||||
- require:
|
|
||||||
- test: postgres-reload-modules
|
|
||||||
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
|
@ -36,9 +34,8 @@ postgres-reload-modules:
|
||||||
{%- for name, tblspace in postgres.tablespaces|dictsort() %}
|
{%- for name, tblspace in postgres.tablespaces|dictsort() %}
|
||||||
|
|
||||||
{{ format_state(name, 'postgres_tablespace', tblspace) }}
|
{{ format_state(name, 'postgres_tablespace', tblspace) }}
|
||||||
- require:
|
|
||||||
- test: postgres-reload-modules
|
|
||||||
{%- if 'owner' in tblspace %}
|
{%- if 'owner' in tblspace %}
|
||||||
|
- require:
|
||||||
- postgres_user: postgres_user-{{ tblspace.owner }}
|
- postgres_user: postgres_user-{{ tblspace.owner }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
@ -49,8 +46,9 @@ postgres-reload-modules:
|
||||||
{%- for name, db in postgres.databases|dictsort() %}
|
{%- for name, db in postgres.databases|dictsort() %}
|
||||||
|
|
||||||
{{ format_state(name, 'postgres_database', db) }}
|
{{ format_state(name, 'postgres_database', db) }}
|
||||||
|
{%- if 'owner' in db or 'tablespace' in db %}
|
||||||
- require:
|
- require:
|
||||||
- test: postgres-reload-modules
|
{%- endif %}
|
||||||
{%- if 'owner' in db %}
|
{%- if 'owner' in db %}
|
||||||
- postgres_user: postgres_user-{{ db.owner }}
|
- postgres_user: postgres_user-{{ db.owner }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
@ -65,9 +63,8 @@ postgres-reload-modules:
|
||||||
{%- for name, schema in postgres.schemas|dictsort() %}
|
{%- for name, schema in postgres.schemas|dictsort() %}
|
||||||
|
|
||||||
{{ format_state(name, 'postgres_schema', schema) }}
|
{{ format_state(name, 'postgres_schema', schema) }}
|
||||||
- require:
|
|
||||||
- test: postgres-reload-modules
|
|
||||||
{%- if 'owner' in schema %}
|
{%- if 'owner' in schema %}
|
||||||
|
- require:
|
||||||
- postgres_user: postgres_user-{{ schema.owner }}
|
- postgres_user: postgres_user-{{ schema.owner }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
@ -78,8 +75,9 @@ postgres-reload-modules:
|
||||||
{%- for name, extension in postgres.extensions|dictsort() %}
|
{%- for name, extension in postgres.extensions|dictsort() %}
|
||||||
|
|
||||||
{{ format_state(name, 'postgres_extension', extension) }}
|
{{ format_state(name, 'postgres_extension', extension) }}
|
||||||
|
{%- if 'maintenance_db' in extension or 'schema' in extension %}
|
||||||
- require:
|
- require:
|
||||||
- test: postgres-reload-modules
|
{%- endif %}
|
||||||
{%- if 'maintenance_db' in extension %}
|
{%- if 'maintenance_db' in extension %}
|
||||||
- postgres_database: postgres_database-{{ extension.maintenance_db }}
|
- postgres_database: postgres_database-{{ extension.maintenance_db }}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
|
@ -95,9 +95,43 @@ RedHat:
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
Suse:
|
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: postgresql-server
|
||||||
pkg_client: postgresql
|
pkg_client: postgresql
|
||||||
pkg_libpq_dev: postgresql
|
pkg_libpq_dev: libqpxx
|
||||||
|
pkg_libs: postgresql-libs
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
MacOS:
|
MacOS:
|
||||||
service: postgresql
|
service: postgresql
|
||||||
|
@ -113,5 +147,4 @@ MacOS:
|
||||||
user: _postgres
|
user: _postgres
|
||||||
group: _postgres
|
group: _postgres
|
||||||
|
|
||||||
|
|
||||||
# vim: ft=sls
|
# vim: ft=sls
|
||||||
|
|
|
@ -48,7 +48,7 @@ postgresql-cluster-prepared:
|
||||||
- name: {{ postgres.prepare_cluster.command }}
|
- name: {{ postgres.prepare_cluster.command }}
|
||||||
- cwd: /
|
- cwd: /
|
||||||
- runas: {{ postgres.prepare_cluster.user }}
|
- runas: {{ postgres.prepare_cluster.user }}
|
||||||
- env: {{ postgres.prepare_cluster.env|default({}) }}
|
- env: {{ postgres.prepare_cluster.env }}
|
||||||
- unless:
|
- unless:
|
||||||
- {{ postgres.prepare_cluster.test }}
|
- {{ postgres.prepare_cluster.test }}
|
||||||
- require:
|
- require:
|
||||||
|
|
Loading…
Add table
Reference in a new issue