mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-16 09:40:26 +00:00
Set sane defaults when use_upstream_repo
and version
Pillars are set
This commit is contained in:
parent
6651ddc498
commit
8db04833c2
6 changed files with 83 additions and 44 deletions
|
@ -1,13 +1,20 @@
|
||||||
postgres:
|
postgres:
|
||||||
pg_hba.conf: salt://postgres/pg_hba.conf
|
# Set True to configure upstream postgresql.org repository for YUM or APT
|
||||||
use_upstream_repo: False
|
use_upstream_repo: False
|
||||||
|
# Version to install from upstream repository
|
||||||
|
version: '9.3'
|
||||||
|
|
||||||
|
# This is Debian/Ubuntu specific package names
|
||||||
pkg: 'postgresql-9.3'
|
pkg: 'postgresql-9.3'
|
||||||
pkg_client: 'postgresql-client-9.3'
|
pkg_client: 'postgresql-client-9.3'
|
||||||
|
|
||||||
|
# Addtional packages to install, this should be in a list format
|
||||||
pkgs_extra:
|
pkgs_extra:
|
||||||
- postgresql-contrib
|
- postgresql-contrib
|
||||||
- postgresql-plpython
|
- postgresql-plpython
|
||||||
|
|
||||||
|
pg_hba.conf: salt://postgres/pg_hba.conf
|
||||||
|
|
||||||
users:
|
users:
|
||||||
localUser:
|
localUser:
|
||||||
ensure: present
|
ensure: present
|
||||||
|
@ -78,3 +85,4 @@ postgres:
|
||||||
postgresconf: |
|
postgresconf: |
|
||||||
listen_addresses = 'localhost,*'
|
listen_addresses = 'localhost,*'
|
||||||
|
|
||||||
|
# vim: ft=yaml:sw=2
|
||||||
|
|
|
@ -1,13 +1,23 @@
|
||||||
{%- macro ubuntu_block(name, version) %}
|
{%- macro ubuntu_block(name, version) %}
|
||||||
|
|
||||||
|
{%- if salt['pillar.get']('postgres:use_upstream_repo', False) %}
|
||||||
|
|
||||||
|
{%- set version = salt['pillar.get']('postgres:version', '9.5') %}
|
||||||
|
|
||||||
|
{%- endif -%}
|
||||||
|
|
||||||
{{ name }}:
|
{{ name }}:
|
||||||
pkg_repo: deb http://apt.postgresql.org/pub/repos/apt/ {{ name }}-pgdg main
|
pkg_repo: deb http://apt.postgresql.org/pub/repos/apt/ {{ name }}-pgdg main
|
||||||
|
pkg: postgresql-{{ version }}
|
||||||
|
pkg_client: postgresql-client-{{ version }}
|
||||||
conf_dir: /etc/postgresql/{{ version }}/main
|
conf_dir: /etc/postgresql/{{ version }}/main
|
||||||
prepare_cluster:
|
prepare_cluster:
|
||||||
command: pg_createcluster {{ version }} main
|
command: pg_createcluster {{ version }} main
|
||||||
test: test -f /var/lib/postgresql/{{ version }}/main/PG_VERSION && test -f /etc/postgresql/{{ version }}/main/postgresql.conf
|
test: test -f /var/lib/postgresql/{{ version }}/main/PG_VERSION && test -f /etc/postgresql/{{ version }}/main/postgresql.conf
|
||||||
user: root
|
user: root
|
||||||
env: {}
|
env: {}
|
||||||
{%- endmacro %}
|
|
||||||
|
{%- endmacro -%}
|
||||||
|
|
||||||
{{ ubuntu_block('wheezy', 9.1) }}
|
{{ ubuntu_block('wheezy', 9.1) }}
|
||||||
|
|
||||||
|
|
|
@ -26,4 +26,3 @@ postgres:
|
||||||
command: service postgresql initdb
|
command: service postgresql initdb
|
||||||
test: test -f /var/lib/pgsql/data/PG_VERSION
|
test: test -f /var/lib/pgsql/data/PG_VERSION
|
||||||
env: {}
|
env: {}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
# -*- mode: yaml -*-
|
# -*- mode: yaml -*-
|
||||||
# vim: syntax=yaml:sw=2
|
|
||||||
|
|
||||||
{% from "postgres/map.jinja" import postgres with context %}
|
{% from "postgres/map.jinja" import postgres with context %}
|
||||||
|
|
||||||
|
@ -8,16 +7,6 @@ include:
|
||||||
- postgres.upstream
|
- postgres.upstream
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
postgresql-config-dir:
|
|
||||||
file.directory:
|
|
||||||
- name: {{ postgres.conf_dir }}
|
|
||||||
- user: {{ postgres.user }}
|
|
||||||
- group: {{ postgres.group }}
|
|
||||||
- makedirs: True
|
|
||||||
- require:
|
|
||||||
- pkg: postgresql-installed
|
|
||||||
- cmd: postgresql-cluster-prepared
|
|
||||||
|
|
||||||
postgresql-installed:
|
postgresql-installed:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- name: {{ postgres.pkg }}
|
- name: {{ postgres.pkg }}
|
||||||
|
@ -38,6 +27,16 @@ postgresql-cluster-prepared:
|
||||||
{{ name }}: {{ value }}
|
{{ name }}: {{ value }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
postgresql-config-dir:
|
||||||
|
file.directory:
|
||||||
|
- name: {{ postgres.conf_dir }}
|
||||||
|
- user: {{ postgres.user }}
|
||||||
|
- group: {{ postgres.group }}
|
||||||
|
- makedirs: True
|
||||||
|
- require:
|
||||||
|
- pkg: postgresql-installed
|
||||||
|
- cmd: postgresql-cluster-prepared
|
||||||
|
|
||||||
postgresql-running:
|
postgresql-running:
|
||||||
service.running:
|
service.running:
|
||||||
- enable: True
|
- enable: True
|
||||||
|
@ -275,4 +274,3 @@ postgresql-ext-{{ ext_name }}-for-db-{{ name }}:
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,3 @@
|
||||||
RedHat:
|
|
||||||
pkg: postgresql-server
|
|
||||||
pkg_client: postgresql
|
|
||||||
pkg_repo: pgdg94
|
|
||||||
repo_baseurl: http://yum.postgresql.org/9.4/redhat/rhel-$releasever-$basearch
|
|
||||||
prepare_cluster:
|
|
||||||
test: test -f /var/lib/pgsql/data/PG_VERSION
|
|
||||||
env: {}
|
|
||||||
{% if grains['os_family'] == 'RedHat' %}
|
|
||||||
{% if grains['osmajorrelease'] >= 7 %}
|
|
||||||
user: root
|
|
||||||
command: postgresql-setup initdb
|
|
||||||
{% else %}
|
|
||||||
user: postgres
|
|
||||||
command: initdb -D /var/lib/pgsql/data
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
Arch:
|
Arch:
|
||||||
conf_dir: /var/lib/postgres/data
|
conf_dir: /var/lib/postgres/data
|
||||||
prepare_cluster:
|
prepare_cluster:
|
||||||
|
@ -24,14 +7,53 @@ Arch:
|
||||||
env: {}
|
env: {}
|
||||||
pkg_client: postgresql
|
pkg_client: postgresql
|
||||||
pkg_dev: postgresql
|
pkg_dev: postgresql
|
||||||
|
|
||||||
Debian:
|
Debian:
|
||||||
pkg_repo_file: /etc/apt/sources.list.d/pgdg.list
|
pkg_repo_file: /etc/apt/sources.list.d/pgdg.list
|
||||||
pkg_dev: postgresql-server-dev-all
|
pkg_dev: postgresql-server-dev-all
|
||||||
pkg_libpq_dev: libpq-dev
|
pkg_libpq_dev: libpq-dev
|
||||||
|
|
||||||
|
FreeBSD:
|
||||||
|
user: pgsql
|
||||||
|
|
||||||
|
OpenBSD:
|
||||||
|
user: _postgresql
|
||||||
|
|
||||||
|
RedHat:
|
||||||
|
{%- if salt['pillar.get']('postgres:use_upstream_repo', False) %}
|
||||||
|
|
||||||
|
{%- set version = salt['pillar.get']('postgres:version', '9.5') %}
|
||||||
|
{%- set release = version|replace('.', '') %}
|
||||||
|
|
||||||
|
version: {{ version }}
|
||||||
|
pkg_repo: pgdg{{ release }}
|
||||||
|
pkg: postgresql{{ release }}-server
|
||||||
|
pkg_client: postgresql{{ release }}
|
||||||
|
conf_dir: /var/lib/pgsql/{{ version }}/data
|
||||||
|
service: postgresql-{{ version }}
|
||||||
|
prepare_cluster:
|
||||||
|
user: postgres
|
||||||
|
command: /usr/pgsql-{{ version }}/bin/initdb -D /var/lib/pgsql/{{ version }}/data
|
||||||
|
test: test -f /var/lib/pgsql/{{ version }}/data/PG_VERSION
|
||||||
|
env: {}
|
||||||
|
|
||||||
|
{%- else %}
|
||||||
|
|
||||||
|
pkg: postgresql-server
|
||||||
|
pkg_client: postgresql
|
||||||
|
prepare_cluster:
|
||||||
|
{%- if grains['osmajorrelease'] >= 7 %}
|
||||||
|
user: root
|
||||||
|
command: postgresql-setup initdb
|
||||||
|
{%- else %}
|
||||||
|
user: postgres
|
||||||
|
command: initdb -D /var/lib/pgsql/data
|
||||||
|
{%- endif %}
|
||||||
|
test: test -f /var/lib/pgsql/data/PG_VERSION
|
||||||
|
env: {}
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
Suse:
|
Suse:
|
||||||
pkg: postgresql-server
|
pkg: postgresql-server
|
||||||
pkg_client: postgresql
|
pkg_client: postgresql
|
||||||
FreeBSD:
|
|
||||||
user: pgsql
|
|
||||||
OpenBSD:
|
|
||||||
user: _postgresql
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{% from "postgres/map.jinja" import postgres with context %}
|
{%- from "postgres/map.jinja" import postgres with context %}
|
||||||
|
|
||||||
|
{%- if grains['os_family'] == 'Debian' %}
|
||||||
|
|
||||||
{% if grains['os_family'] == 'Debian' %}
|
|
||||||
install-postgresql-repo:
|
install-postgresql-repo:
|
||||||
pkgrepo.managed:
|
pkgrepo.managed:
|
||||||
- humanname: PostgreSQL Official Repository
|
- humanname: PostgreSQL Official Repository
|
||||||
|
@ -10,16 +11,16 @@ install-postgresql-repo:
|
||||||
- file: {{ postgres.pkg_repo_file }}
|
- file: {{ postgres.pkg_repo_file }}
|
||||||
- require_in:
|
- require_in:
|
||||||
- pkg: postgresql-installed
|
- pkg: postgresql-installed
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if grains['os_family'] == 'RedHat' %}
|
{%- elif grains['os_family'] == 'RedHat' -%}
|
||||||
|
|
||||||
install-postgresql-repo:
|
install-postgresql-repo:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
|
- name: /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
|
||||||
- source: https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG
|
- source: https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG
|
||||||
- source_hash: md5=78b5db170d33f80ad5a47863a7476b22
|
- source_hash: md5=78b5db170d33f80ad5a47863a7476b22
|
||||||
pkgrepo.managed:
|
pkgrepo.managed:
|
||||||
- name: pgdg-{{ postgres.version }}-centos
|
- name: {{ postgres.pkg_repo }}
|
||||||
- order: 1
|
- order: 1
|
||||||
- humanname: PostgreSQL {{ postgres.version }} $releasever - $basearch
|
- humanname: PostgreSQL {{ postgres.version }} $releasever - $basearch
|
||||||
- baseurl: https://download.postgresql.org/pub/repos/yum/{{ postgres.version }}/redhat/rhel-$releasever-$basearch
|
- baseurl: https://download.postgresql.org/pub/repos/yum/{{ postgres.version }}/redhat/rhel-$releasever-$basearch
|
||||||
|
@ -27,4 +28,5 @@ install-postgresql-repo:
|
||||||
- gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
|
- gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
|
||||||
- require:
|
- require:
|
||||||
- file: install-postgresql-repo
|
- file: install-postgresql-repo
|
||||||
{% endif %}
|
|
||||||
|
{%- endif %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue