mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-15 17:20:25 +00:00
Merge branch 'master' into python
This commit is contained in:
commit
e6be41aa15
14 changed files with 73 additions and 52 deletions
|
@ -1,4 +1,4 @@
|
||||||
{%- from "postgres/map.jinja" import postgres with context -%}
|
{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres with context -%}
|
||||||
|
|
||||||
{%- set pkgs = [] %}
|
{%- set pkgs = [] %}
|
||||||
{%- for pkg in (postgres.pkg_client, postgres.pkg_libpq_dev) %}
|
{%- for pkg in (postgres.pkg_client, postgres.pkg_libpq_dev) %}
|
||||||
|
@ -27,8 +27,9 @@ postgresql-client-libs:
|
||||||
{%- for bin in postgres.client_bins %}
|
{%- for bin in postgres.client_bins %}
|
||||||
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
|
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
|
||||||
|
|
||||||
{{ bin }}:
|
postgresql-{{ bin }}-altinstall:
|
||||||
alternatives.install:
|
alternatives.install:
|
||||||
|
- name: {{ bin }}
|
||||||
- link: {{ salt['file.join']('/usr/bin', bin) }}
|
- link: {{ salt['file.join']('/usr/bin', bin) }}
|
||||||
- path: {{ path }}
|
- path: {{ path }}
|
||||||
- priority: {{ postgres.linux.altpriority }}
|
- priority: {{ postgres.linux.altpriority }}
|
|
@ -2,28 +2,27 @@
|
||||||
|
|
||||||
{% import_yaml "postgres/repo.yaml" as repo %}
|
{% import_yaml "postgres/repo.yaml" as repo %}
|
||||||
|
|
||||||
{% macro debian_codename(name, version, codename=none) %}
|
{# Generate lookup dictionary map for OS and derivative distributions
|
||||||
{#
|
name: distro codename
|
||||||
Generate lookup dictionary map for Debian and derivative distributions
|
version: PostgreSQL release version
|
||||||
|
codename: optional grain value if `name` does not match the one returned by `oscodename` grain
|
||||||
name:
|
|
||||||
distro codename
|
|
||||||
version:
|
|
||||||
PostgreSQL release version
|
|
||||||
codename:
|
|
||||||
optional grain value if `name` does not match the one returned by
|
|
||||||
`oscodename` grain
|
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
{% macro debian_codename(name, version, codename=none) %}
|
||||||
|
|
||||||
{# use upstream version if configured #}
|
{# use upstream version if configured #}
|
||||||
{% if repo.use_upstream_repo == true %}
|
{% if repo.use_upstream_repo == true %}
|
||||||
{% set version = repo.version %}
|
{% set version = repo.version %}
|
||||||
|
{% set fromrepo = repo.fromrepo or name + '-pgdg' %}
|
||||||
|
{% else %}
|
||||||
|
{% set fromrepo = name %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ codename|default(name, true) }}:
|
{{ codename|default(name, true) }}:
|
||||||
# PostgreSQL packages are mostly downloaded from `main` repo component
|
# PostgreSQL packages are mostly downloaded from `main` repo component
|
||||||
|
fromrepo: {{ fromrepo }}
|
||||||
pkg_repo:
|
pkg_repo:
|
||||||
name: 'deb http://apt.postgresql.org/pub/repos/apt {{ name }}-pgdg main {{ repo.version }}'
|
name: 'deb http://apt.postgresql.org/pub/repos/apt {{ name }}-pgdg main {{ version }}'
|
||||||
pkg: postgresql-{{ version }}
|
pkg: postgresql-{{ version }}
|
||||||
pkg_client: postgresql-client-{{ version }}
|
pkg_client: postgresql-client-{{ version }}
|
||||||
conf_dir: /etc/postgresql/{{ version }}/main
|
conf_dir: /etc/postgresql/{{ version }}/main
|
||||||
|
@ -36,25 +35,18 @@
|
||||||
|
|
||||||
|
|
||||||
{% macro fedora_codename(name, version, codename=none) %}
|
{% macro fedora_codename(name, version, codename=none) %}
|
||||||
{#
|
|
||||||
Generate lookup dictionary map for Fedora distributions
|
|
||||||
|
|
||||||
name:
|
|
||||||
distro codename
|
|
||||||
version:
|
|
||||||
PostgreSQL release version
|
|
||||||
codename:
|
|
||||||
optional grain value if `name` does not match the one returned by
|
|
||||||
`oscodename` grain
|
|
||||||
#}
|
|
||||||
|
|
||||||
{# use upstream version if configured #}
|
{# use upstream version if configured #}
|
||||||
{% if repo.use_upstream_repo == true %}
|
{% if repo.use_upstream_repo == true %}
|
||||||
|
{% set fromrepo = repo.fromrepo or name + '-pgdg' %}
|
||||||
{% set version = repo.version %}
|
{% set version = repo.version %}
|
||||||
|
{% else %}
|
||||||
|
{% set fromrepo = name %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ codename|default(name, true) }}:
|
{{ codename|default(name, true) }}:
|
||||||
# PostgreSQL packages are mostly downloaded from `main` repo component
|
# PostgreSQL packages are mostly downloaded from `main` repo component
|
||||||
|
fromrepo: {{ name }}
|
||||||
pkg_repo:
|
pkg_repo:
|
||||||
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ version }}/fedora/fedora-$releasever-$basearch'
|
baseurl: 'https://download.postgresql.org/pub/repos/yum/{{ version }}/fedora/fedora-$releasever-$basearch'
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ postgres:
|
||||||
env: []
|
env: []
|
||||||
|
|
||||||
conf_dir: /var/lib/pgsql/data
|
conf_dir: /var/lib/pgsql/data
|
||||||
|
conf_dir_mode: '0700'
|
||||||
postgresconf: ""
|
postgresconf: ""
|
||||||
|
|
||||||
macos:
|
macos:
|
||||||
|
@ -56,6 +57,8 @@ postgres:
|
||||||
|
|
||||||
bake_image: False
|
bake_image: False
|
||||||
|
|
||||||
|
fromrepo:
|
||||||
|
|
||||||
users: {}
|
users: {}
|
||||||
tablespaces: {}
|
tablespaces: {}
|
||||||
databases: {}
|
databases: {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% from "postgres/map.jinja" import postgres with context %}
|
{% from tpldir + "/map.jinja" import postgres with context %}
|
||||||
|
|
||||||
{% if grains.os not in ('Windows', 'MacOS',) %}
|
{% if grains.os not in ('Windows', 'MacOS',) %}
|
||||||
|
|
||||||
|
@ -6,18 +6,37 @@
|
||||||
install-postgres-dev-package:
|
install-postgres-dev-package:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- name: {{ postgres.pkg_dev }}
|
- name: {{ postgres.pkg_dev }}
|
||||||
|
{% if postgres.fromrepo %}
|
||||||
|
- fromrepo: {{ postgres.fromrepo }}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if postgres.pkg_libpq_dev %}
|
{% if postgres.pkg_libpq_dev %}
|
||||||
install-postgres-libpq-dev:
|
install-postgres-libpq-dev:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- name: {{ postgres.pkg_libpq_dev }}
|
- name: {{ postgres.pkg_libpq_dev }}
|
||||||
|
{% if postgres.fromrepo %}
|
||||||
|
- fromrepo: {{ postgres.fromrepo }}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% 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
|
# Darwin maxfiles limits
|
||||||
{% if postgres.limits.soft or postgres.limits.hard %}
|
{% if postgres.limits.soft or postgres.limits.hard %}
|
||||||
|
@ -25,7 +44,7 @@ install-postgres-libpq-dev:
|
||||||
postgres_maxfiles_limits_conf:
|
postgres_maxfiles_limits_conf:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: /Library/LaunchDaemons/limit.maxfiles.plist
|
- name: /Library/LaunchDaemons/limit.maxfiles.plist
|
||||||
- source: salt://postgres/templates/limit.maxfiles.plist
|
- source: salt://{{ tpldir }}/templates/limit.maxfiles.plist
|
||||||
- context:
|
- context:
|
||||||
soft_limit: {{ postgres.limits.soft or postgres.limits.hard }}
|
soft_limit: {{ postgres.limits.soft or postgres.limits.hard }}
|
||||||
hard_limit: {{ postgres.limits.hard or postgres.limits.soft }}
|
hard_limit: {{ postgres.limits.hard or postgres.limits.soft }}
|
||||||
|
@ -43,7 +62,7 @@ postgres-desktop-shortcut-clean:
|
||||||
postgres-desktop-shortcut-add:
|
postgres-desktop-shortcut-add:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: /tmp/mac_shortcut.sh
|
- name: /tmp/mac_shortcut.sh
|
||||||
- source: salt://postgres/templates/mac_shortcut.sh
|
- source: salt://{{ tpldir }}/templates/mac_shortcut.sh
|
||||||
- mode: 755
|
- mode: 755
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- context:
|
- context:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% from "postgres/map.jinja" import postgres with context %}
|
{% from tpldir + "/map.jinja" import postgres with context %}
|
||||||
|
|
||||||
postgresql-dead:
|
postgresql-dead:
|
||||||
service.dead:
|
service.dead:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% from "postgres/map.jinja" import postgres with context %}
|
{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres with context -%}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
{% if postgres.use_upstream_repo == 'postgresapp' %}
|
{% if postgres.use_upstream_repo == 'postgresapp' %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% from "postgres/map.jinja" import postgres as pg with context %}
|
{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres as pg with context -%}
|
||||||
|
|
||||||
# Cleanup first
|
# Cleanup first
|
||||||
pg-remove-prev-archive:
|
pg-remove-prev-archive:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{%- from "postgres/map.jinja" import postgres with context -%}
|
{%- from tpldir + "/map.jinja" import postgres with context -%}
|
||||||
{%- from "postgres/macros.jinja" import format_state with context -%}
|
{%- from tpldir + "/macros.jinja" import format_state with context -%}
|
||||||
|
|
||||||
{%- if salt['postgres.user_create']|default(none) is not callable %}
|
{%- if salt['postgres.user_create']|default(none) is not callable %}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ RedHat:
|
||||||
{% if repo.use_upstream_repo == true %}
|
{% if repo.use_upstream_repo == true %}
|
||||||
{% set data_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
{% set data_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
||||||
|
|
||||||
|
fromrepo: pgdg{{ release }}
|
||||||
pkg: postgresql{{ release }}-server
|
pkg: postgresql{{ release }}-server
|
||||||
pkg_client: postgresql{{ release }}
|
pkg_client: postgresql{{ release }}
|
||||||
pkg_libs: postgresql{{ release }}-libs
|
pkg_libs: postgresql{{ release }}-libs
|
||||||
|
@ -56,6 +57,8 @@ RedHat:
|
||||||
|
|
||||||
# directory containing PostgreSQL client executables
|
# directory containing PostgreSQL client executables
|
||||||
bin_dir: /usr/pgsql-{{ repo.version }}/bin
|
bin_dir: /usr/pgsql-{{ repo.version }}/bin
|
||||||
|
dev_bins:
|
||||||
|
- ecg
|
||||||
client_bins:
|
client_bins:
|
||||||
- clusterdb
|
- clusterdb
|
||||||
- createdb
|
- createdb
|
||||||
|
@ -112,6 +115,7 @@ Suse:
|
||||||
{% if repo.use_upstream_repo == true %}
|
{% if repo.use_upstream_repo == true %}
|
||||||
{% set lib_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
{% set lib_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
||||||
|
|
||||||
|
fromrepo: pgdg-sles-{{ release }}
|
||||||
pkg: postgresql{{ release }}-server
|
pkg: postgresql{{ release }}-server
|
||||||
pkg_client: postgresql{{ release }}
|
pkg_client: postgresql{{ release }}
|
||||||
pkg_dev: postgresql{{ release }}-devel
|
pkg_dev: postgresql{{ release }}-devel
|
||||||
|
@ -129,6 +133,8 @@ Suse:
|
||||||
|
|
||||||
# directory containing PostgreSQL client executables
|
# directory containing PostgreSQL client executables
|
||||||
bin_dir: /usr/pgsql-{{ repo.version }}/bin
|
bin_dir: /usr/pgsql-{{ repo.version }}/bin
|
||||||
|
dev_bins:
|
||||||
|
- ecg
|
||||||
client_bins:
|
client_bins:
|
||||||
- pg_archivecleanup
|
- pg_archivecleanup
|
||||||
- pg_config
|
- pg_config
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{% from "postgres/map.jinja" import postgres with context %}
|
{% from tpldir + "/map.jinja" import postgres with context %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- postgres.upstream
|
- postgres.upstream
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
|
|
||||||
{% import_yaml "postgres/defaults.yaml" as defaults %}
|
{% import_yaml "postgres/defaults.yaml" as defaults %}
|
||||||
|
|
||||||
use_upstream_repo: {{ salt['pillar.get']('postgres:use_upstream_repo',
|
use_upstream_repo: {{ salt['pillar.get']('postgres:use_upstream_repo', defaults.postgres.use_upstream_repo) }}
|
||||||
defaults.postgres.use_upstream_repo) }}
|
version: {{ salt['pillar.get']('postgres:version', defaults.postgres.version) }}
|
||||||
version: {{ salt['pillar.get']('postgres:version',
|
fromrepo: {{ salt['pillar.get']('postgres:fromrepo', defaults.postgres.fromrepo) }}
|
||||||
defaults.postgres.version) }}
|
|
||||||
|
|
||||||
#Early lookup for system user on MacOS
|
#Early lookup for system user on MacOS
|
||||||
{% if grains.os == 'MacOS' %}
|
{% if grains.os == 'MacOS' %}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{%- from "postgres/map.jinja" import postgres with context -%}
|
{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres with context -%}
|
||||||
|
|
||||||
# This state is used to launch PostgreSQL with ``pg_ctl`` command and enable it
|
# This state is used to launch PostgreSQL with ``pg_ctl`` command and enable it
|
||||||
# on "boot" during an image (Docker, Virtual Appliance, AMI) preparation
|
# on "boot" during an image (Docker, Virtual Appliance, AMI) preparation
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{%- from "postgres/map.jinja" import postgres with context %}
|
{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres with context -%}
|
||||||
|
|
||||||
{%- set includes = [] %}
|
{%- set includes = [] %}
|
||||||
{%- if postgres.bake_image %}
|
{%- if postgres.bake_image %}
|
||||||
|
@ -23,6 +23,9 @@ postgresql-server:
|
||||||
- require:
|
- require:
|
||||||
- pkgrepo: postgresql-repo
|
- pkgrepo: postgresql-repo
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if postgres.fromrepo %}
|
||||||
|
- fromrepo: {{ postgres.fromrepo }}
|
||||||
|
{%- endif %}
|
||||||
{%- if grains.os == 'MacOS' %}
|
{%- if grains.os == 'MacOS' %}
|
||||||
#Register as Launchd LaunchAgent for system users
|
#Register as Launchd LaunchAgent for system users
|
||||||
- require_in:
|
- require_in:
|
||||||
|
@ -40,8 +43,9 @@ postgresql-server:
|
||||||
{%- for bin in postgres.server_bins %}
|
{%- for bin in postgres.server_bins %}
|
||||||
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
|
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
|
||||||
|
|
||||||
{{ bin }}:
|
postgresql-{{ bin }}-altinstall:
|
||||||
alternatives.install:
|
alternatives.install:
|
||||||
|
- name: {{ bin }}
|
||||||
- link: {{ salt['file.join']('/usr/bin', bin) }}
|
- link: {{ salt['file.join']('/usr/bin', bin) }}
|
||||||
- path: {{ path }}
|
- path: {{ path }}
|
||||||
- priority: {{ postgres.linux.altpriority }}
|
- priority: {{ postgres.linux.altpriority }}
|
||||||
|
@ -72,7 +76,7 @@ postgresql-config-dir:
|
||||||
- name: {{ postgres.conf_dir }}
|
- name: {{ postgres.conf_dir }}
|
||||||
- user: {{ postgres.user }}
|
- user: {{ postgres.user }}
|
||||||
- group: {{ postgres.group }}
|
- group: {{ postgres.group }}
|
||||||
- dir_mode: 775
|
- dir_mode: {{ postgres.conf_dir_mode }}
|
||||||
- force: True
|
- force: True
|
||||||
- file_mode: 644
|
- file_mode: 644
|
||||||
- recurse:
|
- recurse:
|
||||||
|
@ -114,7 +118,7 @@ postgresql-pg_hba:
|
||||||
- source: {{ postgres['pg_hba.conf'] }}
|
- source: {{ postgres['pg_hba.conf'] }}
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- defaults:
|
- defaults:
|
||||||
acls: {{ postgres.acls }}
|
acls: {{ postgres.acls|yaml() }}
|
||||||
{%- if postgres.config_backup %}
|
{%- if postgres.config_backup %}
|
||||||
# Create the empty file before managing to overcome the limitation of check_cmd
|
# Create the empty file before managing to overcome the limitation of check_cmd
|
||||||
- onlyif: test -f {{ pg_hba_path }} || touch {{ pg_hba_path }}
|
- onlyif: test -f {{ pg_hba_path }} || touch {{ pg_hba_path }}
|
||||||
|
@ -141,7 +145,7 @@ postgresql-pg_ident:
|
||||||
- source: {{ postgres['pg_ident.conf'] }}
|
- source: {{ postgres['pg_ident.conf'] }}
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- defaults:
|
- defaults:
|
||||||
mappings: {{ postgres.identity_map }}
|
mappings: {{ postgres.identity_map|yaml() }}
|
||||||
{%- if postgres.config_backup %}
|
{%- if postgres.config_backup %}
|
||||||
# Create the empty file before managing to overcome the limitation of check_cmd
|
# Create the empty file before managing to overcome the limitation of check_cmd
|
||||||
- onlyif: test -f {{ pg_ident_path }} || touch {{ pg_ident_path }}
|
- onlyif: test -f {{ pg_ident_path }} || touch {{ pg_ident_path }}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{%- from "postgres/map.jinja" import postgres with context -%}
|
{%- from tpldir + "/map.jinja" import postgres with context -%}
|
||||||
{%- from "postgres/macros.jinja" import format_kwargs with context -%}
|
{%- from tpldir + "/macros.jinja" import format_kwargs with context -%}
|
||||||
|
|
||||||
{%- if 'pkg_repo' in postgres -%}
|
{%- if 'pkg_repo' in postgres -%}
|
||||||
|
|
||||||
|
@ -22,14 +22,11 @@ postgresql-repo:
|
||||||
|
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
|
||||||
{%- else -%}
|
{%- elif grains.os not in ('Windows', 'MacOS',) %}
|
||||||
|
|
||||||
# Notify that we don't manage this distro
|
|
||||||
{% if grains.os not in ('Windows', 'MacOS',) %}
|
|
||||||
postgresql-repo:
|
postgresql-repo:
|
||||||
test.show_notification:
|
test.show_notification:
|
||||||
- text: |
|
- text: |
|
||||||
PostgreSQL does not provide package repository for {{ grains['osfinger'] }}
|
PostgreSQL does not provide package repository for {{ grains['osfinger'] }}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue