2014-01-26 04:36:15 +00:00
|
|
|
{% from "postgres/map.jinja" import postgres with context %}
|
2014-01-26 04:06:22 +00:00
|
|
|
|
2013-07-16 10:23:53 -06:00
|
|
|
postgresql:
|
2014-01-26 04:06:22 +00:00
|
|
|
pkg:
|
|
|
|
- installed
|
|
|
|
- name: {{ postgres.pkg }}
|
2014-02-09 17:50:23 +01:00
|
|
|
service:
|
|
|
|
- running
|
|
|
|
- enable: true
|
|
|
|
- name: {{ postgres.service }}
|
|
|
|
- require:
|
|
|
|
- pkg: {{ postgres.pkg }}
|
2014-07-27 01:55:47 -04:00
|
|
|
|
|
|
|
postgresql-server-dev-9.3:
|
|
|
|
pkg.installed
|
2013-07-16 10:23:53 -06:00
|
|
|
|
2014-05-29 13:01:39 -06:00
|
|
|
{% if 'pg_hba.conf' in pillar.get('postgres', {}) %}
|
2014-05-15 14:44:39 -07:00
|
|
|
pg_hba.conf:
|
|
|
|
file.managed:
|
|
|
|
- name: {{ postgres.pg_hba }}
|
2014-07-13 19:17:24 +00:00
|
|
|
- source: {{ salt['pillar.get']('postgres:pg_hba.conf', 'salt://postgres/pg_hba.conf') }}
|
2014-05-15 15:31:42 -07:00
|
|
|
- template: jinja
|
2014-05-15 14:44:39 -07:00
|
|
|
- user: postgres
|
|
|
|
- group: postgres
|
|
|
|
- mode: 644
|
|
|
|
- require:
|
2014-05-15 15:06:04 -07:00
|
|
|
- pkg: {{ postgres.pkg }}
|
2014-05-16 11:03:35 -06:00
|
|
|
- watch_in:
|
|
|
|
- service: postgresql
|
2014-05-16 10:56:10 -06:00
|
|
|
{% endif %}
|
2014-05-15 15:06:04 -07:00
|
|
|
|
2014-05-29 13:01:39 -06:00
|
|
|
{% if 'db' in pillar.get('postgres', {}) %}
|
2014-05-15 15:06:04 -07:00
|
|
|
postgres-app-user:
|
|
|
|
postgres_user.present:
|
2014-07-13 19:17:24 +00:00
|
|
|
- name: {{ salt['pillar.get']('postgres:db:user', 'myuser') }}
|
|
|
|
- createdb: {{ salt['pillar.get']('postgres:db:createdb', False) }}
|
|
|
|
- password: {{ salt['pillar.get']('postgres:db:password', 'mypass') }}
|
2014-05-15 15:06:04 -07:00
|
|
|
- runas: postgres
|
|
|
|
- require:
|
|
|
|
- service: {{ postgres.service }}
|
|
|
|
|
|
|
|
postgres-app-db:
|
|
|
|
postgres_database.present:
|
2014-07-13 19:17:24 +00:00
|
|
|
- name: {{ salt['pillar.get']('postgres:db:name', 'mydb') }}
|
2014-05-15 15:06:04 -07:00
|
|
|
- encoding: UTF8
|
|
|
|
- lc_ctype: en_US.UTF8
|
|
|
|
- lc_collate: en_US.UTF8
|
|
|
|
- template: template0
|
2014-07-13 19:17:24 +00:00
|
|
|
- owner: {{ salt['pillar.get']('postgres:db:user', 'myuser') }}
|
2014-05-15 15:06:04 -07:00
|
|
|
- runas: postgres
|
|
|
|
- require:
|
|
|
|
- postgres_user: postgres-app-user
|
2014-05-16 10:59:19 -06:00
|
|
|
{% endif %}
|