mirror of
https://github.com/saltstack-formulas/postgres-formula.git
synced 2025-04-15 17:20:25 +00:00
Allow configuration of cluster name
, locale
& encoding
This commit is contained in:
parent
9865664963
commit
34aae257e5
5 changed files with 25 additions and 4 deletions
|
@ -26,6 +26,13 @@ postgres:
|
|||
- postgresql-contrib
|
||||
- postgresql-plpython
|
||||
|
||||
# CLUSTER
|
||||
# The default `encoding` is derived from the `locale` so not recommended
|
||||
# to provide a value for it unless necessary
|
||||
cluster:
|
||||
locale: en_GB.UTF-8
|
||||
# encoding: UTF8
|
||||
|
||||
#'Alternatives system' priority incremental. 0 disables feature.
|
||||
linux:
|
||||
altpriority: 30
|
||||
|
|
|
@ -16,8 +16,9 @@
|
|||
{% else %}
|
||||
{% set fromrepo = name %}
|
||||
{% endif %}
|
||||
{% set conf_dir = '/etc/postgresql/' ~ version ~ '/main' %}
|
||||
{% set data_dir = '/var/lib/postgresql/' ~ version ~ '/main' %}
|
||||
{% set cluster_name = repo.cluster_name %}
|
||||
{% set conf_dir = '/etc/postgresql/{0}/{1}'.format(version, cluster_name) %}
|
||||
{% set data_dir = '/var/lib/postgresql/{0}/{1}'.format(version, cluster_name) %}
|
||||
|
||||
{{ codename|default(name, true) }}:
|
||||
# PostgreSQL packages are mostly downloaded from `main` repo component
|
||||
|
@ -29,7 +30,7 @@
|
|||
pkg: postgresql-{{ version }}
|
||||
pkg_client: postgresql-client-{{ version }}
|
||||
prepare_cluster:
|
||||
pgcommand: pg_createcluster {{ version }} main -d
|
||||
pgcommand: pg_createcluster {{ version }} {{ cluster_name }} -d
|
||||
user: root
|
||||
|
||||
{% endmacro %}
|
||||
|
|
|
@ -21,6 +21,11 @@ postgres:
|
|||
user: postgres
|
||||
env: []
|
||||
|
||||
cluster:
|
||||
name: main # Debian-based only
|
||||
locale: '' # Defaults to `C`
|
||||
encoding: '' # Defaults to `SQL_ASCII` if `locale` not provided
|
||||
|
||||
conf_dir: /var/lib/pgsql/data
|
||||
data_dir: /var/lib/pgsql/data
|
||||
conf_dir_mode: '0700'
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
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) }}
|
||||
cluster_name: {{ salt['pillar.get']('postgres:cluster:name', defaults.postgres.cluster.name) }}
|
||||
|
||||
#Early lookup for system user on MacOS
|
||||
{% if grains.os == 'MacOS' %}
|
||||
|
|
|
@ -76,7 +76,14 @@ postgresql-cluster-prepared:
|
|||
- name: {{ postgres.prepare_cluster.command }}
|
||||
- unless: {{ postgres.prepare_cluster.test }}
|
||||
{%- else %}
|
||||
- name: {{ postgres.prepare_cluster.pgcommand }} {{ postgres.data_dir }}
|
||||
{%- set cc_cmd = '{0} {1}'.format(postgres.prepare_cluster.pgcommand, postgres.data_dir) %}
|
||||
{%- if postgres.cluster.locale %}
|
||||
{%- set cc_cmd = '{0} --locale={1}'.format(cc_cmd, postgres.cluster.locale) %}
|
||||
{%- endif %}
|
||||
{%- if postgres.cluster.encoding %}
|
||||
{%- set cc_cmd = '{0} --encoding={1}'.format(cc_cmd, postgres.cluster.encoding) %}
|
||||
{%- endif %}
|
||||
- name: {{ cc_cmd }}
|
||||
- unless: test -f {{ postgres.data_dir }}/{{ postgres.prepare_cluster.pgtestfile }}
|
||||
{%- endif %}
|
||||
- cwd: /
|
||||
|
|
Loading…
Add table
Reference in a new issue