Kill create_cluster pillar switch, refs: #100
It is just a variant of init_db. A more correct solution would be to support configuring a different initdb command while passing values from the pillar by default like version. This would make it truly generic but is probably not achievable given current pillar self-referencing capabilities (ie. none). Thus, I decided to make it OS family specific since Debian provides its own tools to manage clusters, etc. Gentoo also has a specific way to initialize a new cluster which does not fit with commands.initdb so the current if/elif would be extended when support is added for Gentoo.
This commit is contained in:
@@ -8,8 +8,6 @@ postgres:
|
|||||||
service: postgresql
|
service: postgresql
|
||||||
conf_dir: /var/lib/pgsql/data
|
conf_dir: /var/lib/pgsql/data
|
||||||
data_dir: /var/lib/pgsql/data
|
data_dir: /var/lib/pgsql/data
|
||||||
create_cluster: False
|
|
||||||
init_db: False
|
|
||||||
version: 9.1
|
version: 9.1
|
||||||
use_upstream_repo: False
|
use_upstream_repo: False
|
||||||
users: {}
|
users: {}
|
||||||
@@ -19,9 +17,10 @@ postgres:
|
|||||||
postgresconf_backup: True
|
postgresconf_backup: True
|
||||||
postgresconf: ""
|
postgresconf: ""
|
||||||
pg_hba.conf: salt://postgres/pg_hba.conf
|
pg_hba.conf: salt://postgres/pg_hba.conf
|
||||||
commands:
|
initdb: True
|
||||||
initdb: service postgresql initdb
|
|
||||||
initdb_user: root
|
initdb_user: root
|
||||||
initdb_args: --data-checksum
|
initdb_args: --data-checksum
|
||||||
|
commands:
|
||||||
|
initdb: service postgresql initdb
|
||||||
user: postgres
|
user: postgres
|
||||||
group: postgres
|
group: postgres
|
||||||
|
|||||||
@@ -28,34 +28,18 @@ postgresql-installed:
|
|||||||
# make sure the data directory and contents have been initialized
|
# make sure the data directory and contents have been initialized
|
||||||
postgresql-cluster-prepared:
|
postgresql-cluster-prepared:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- cwd: /
|
{% if postgres.initdb %}
|
||||||
{% if postgres.create_cluster != False %}
|
|
||||||
- user: root
|
|
||||||
- name: pg_createcluster {{ postgres.version }} main
|
|
||||||
{% else %}
|
|
||||||
- name: test -f {{ postgres.conf_dir }}/environment
|
|
||||||
{% endif %}
|
|
||||||
- unless:
|
|
||||||
- test -f {{ postgres.conf_dir }}/environment
|
|
||||||
- require:
|
|
||||||
- pkg: postgresql-installed
|
|
||||||
- env:
|
|
||||||
LC_ALL: C.UTF-8
|
|
||||||
|
|
||||||
postgresql-db-prepared:
|
|
||||||
cmd.run:
|
|
||||||
{% if postgres.init_db != False %}
|
|
||||||
- user: {{ postgres.initdb_user }}
|
|
||||||
- name: {{ postgres.commands.initdb }} {{ postgres.initdb_args }} -D {{ postgres.data_dir }}
|
- name: {{ postgres.commands.initdb }} {{ postgres.initdb_args }} -D {{ postgres.data_dir }}
|
||||||
|
{% elif grains.os_family == 'Debian' %}
|
||||||
{% else %}
|
- name: pg_createcluster {{ postgres.version }} main
|
||||||
- name: test -f {{ postgres.data_dir }}/PG_VERSION
|
{# else: TODO #}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
- cwd: /
|
||||||
|
- user: {{ postgres.initdb_user }}
|
||||||
- unless:
|
- unless:
|
||||||
- test -f {{ postgres.data_dir }}/PG_VERSION
|
- test -f {{ postgres.data_dir }}/PG_VERSION
|
||||||
- require:
|
- require:
|
||||||
- pkg: postgresql-installed
|
- pkg: postgresql-installed
|
||||||
- cmd: postgresql-cluster-prepared
|
|
||||||
- env:
|
- env:
|
||||||
LC_ALL: C.UTF-8
|
LC_ALL: C.UTF-8
|
||||||
|
|
||||||
@@ -67,7 +51,6 @@ postgresql-running:
|
|||||||
- reload: true
|
- reload: true
|
||||||
- require:
|
- require:
|
||||||
- cmd: postgresql-cluster-prepared
|
- cmd: postgresql-cluster-prepared
|
||||||
- cmd: postgresql-db-prepared
|
|
||||||
|
|
||||||
{% if postgres.pkgs_extra %}
|
{% if postgres.pkgs_extra %}
|
||||||
postgresql-extra-pkgs-installed:
|
postgresql-extra-pkgs-installed:
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
RedHat:
|
RedHat:
|
||||||
init_db: True
|
initdb_user: postgres
|
||||||
commands:
|
commands:
|
||||||
initdb: initdb
|
initdb: initdb
|
||||||
initdb_user: postgres
|
|
||||||
pkg: postgresql-server
|
pkg: postgresql-server
|
||||||
pkg_client: postgresql
|
pkg_client: postgresql
|
||||||
pkg_repo: pgdg94
|
pkg_repo: pgdg94
|
||||||
@@ -10,7 +9,6 @@ RedHat:
|
|||||||
Arch:
|
Arch:
|
||||||
conf_dir: /var/lib/postgres/data
|
conf_dir: /var/lib/postgres/data
|
||||||
data_dir: /var/lib/postgres/data
|
data_dir: /var/lib/postgres/data
|
||||||
init_db: True
|
|
||||||
initdb_user: postgres
|
initdb_user: postgres
|
||||||
commands:
|
commands:
|
||||||
initdb: initdb --locale en_US.UTF8 -E UTF8 -D "/var/lib/postgres/data"
|
initdb: initdb --locale en_US.UTF8 -E UTF8 -D "/var/lib/postgres/data"
|
||||||
@@ -19,11 +17,11 @@ Arch:
|
|||||||
Debian:
|
Debian:
|
||||||
pkg_repo_file: /etc/apt/sources.list.d/pgdg.list
|
pkg_repo_file: /etc/apt/sources.list.d/pgdg.list
|
||||||
pkg_libpq_dev: libpq-dev
|
pkg_libpq_dev: libpq-dev
|
||||||
|
initdb: False
|
||||||
Suse:
|
Suse:
|
||||||
init_db: True
|
initdb_user: postgres
|
||||||
commands:
|
commands:
|
||||||
initdb: initdb
|
initdb: initdb
|
||||||
initdb_user: postgres
|
|
||||||
pkg: postgresql-server
|
pkg: postgresql-server
|
||||||
pkg_client: postgresql
|
pkg_client: postgresql
|
||||||
FreeBSD:
|
FreeBSD:
|
||||||
|
|||||||
Reference in New Issue
Block a user