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