Fixes to db init
diff --git a/postgresql/map.jinja b/postgresql/map.jinja
index 6d6e016..5ea87f2 100644
--- a/postgresql/map.jinja
+++ b/postgresql/map.jinja
@@ -2,7 +2,7 @@
{%- set server = salt['grains.filter_by']({
'Debian': {
'pkgs': ['postgresql-'+version, 'postgresql-contrib-'+version, 'postgresql-doc-'+version, 'postgresql-server-dev-'+version],
- 'service': 'postgres',
+ 'service': 'postgresql',
'version': version,
'init_command': 'pg_createcluster '+version+' main --start',
'dir': {
@@ -12,7 +12,7 @@
},
'RedHat': {
'pkgs': ['postgresql-server', 'postgresql-contrib'],
- 'service': 'postgres',
+ 'service': 'postgresql',
'version': version,
'init_command': 'service postgresql initdb',
'dir': {
diff --git a/postgresql/server.sls b/postgresql/server.sls
index d01137d..1245178 100644
--- a/postgresql/server.sls
+++ b/postgresql/server.sls
@@ -7,7 +7,7 @@
init_postgresql_cluster:
cmd.run:
- - name: pg_createcluster {{ server.version }} main --start
+ - name: {{ server.init_command }}
- unless: "[ -f {{ server.dir.config }}/postgresql.conf ]"
- cwd: /root
- require:
@@ -21,7 +21,7 @@
- group: postgres
- mode: 600
- require:
- - pkg: postgresql_packages
+ - cmd: init_postgresql_cluster
{{ server.dir.config }}/postgresql.conf:
file.managed:
@@ -33,7 +33,7 @@
postgresql_version: {{ server.version }}
- mode: 600
- require:
- - pkg: postgresql_packages
+ - cmd: init_postgresql_cluster
/root/.pgpass:
file.managed:
@@ -43,11 +43,12 @@
- group: root
- mode: 600
- require:
- - pkg: postgresql_packages
+ - cmd: init_postgresql_cluster
postgresql_service:
service.running:
- - name: postgresql
+ - name: {{ server.service }}
+ - enable: true
- watch:
- file: {{ server.dir.config }}/pg_hba.conf
- file: {{ server.dir.config }}/postgresql.conf