Skip to content

Instantly share code, notes, and snippets.

@kitplummer

kitplummer/pg state

Created Sep 28, 2015
Embed
What would you like to do?
postgresql-repo:
pkg.installed:
- sources:
- pgdg-centos94: http://{{ pillar['pg_yum_domain']}}/9.4/redhat/rhel-6-x86_64/pgdg-centos94-9.4-1.noarch.rpm
postgresql-install:
pkg.installed:
- names:
- postgresql94
- postgresql94-server
- postgis2_94
service.running:
- name: postgresql-9.4
- enable: True
- watch:
- file: /var/lib/pgsql/9.4/data/pg_hba.conf
- file: /var/lib/pgsql/9.4/data/postgresql.conf
/etc/ld.so.conf.d/hdf5-libs.conf:
file.managed:
- source: salt://postgresql/hdf5-libs.conf
- user: root
- mode: 0644
ldconfig:
cmd.run:
- user: root
postgresql-first-run-init:
cmd.run:
- cwd: /
- user: root
- names:
- service postgresql-9.4 initdb
- unless: stat /var/lib/pgsql/9.4/data/postgresql.conf
- require:
- pkg: postgresql94-server
/var/lib/pgsql/9.4/data/postgresql.conf:
file.managed:
- source: salt://postgresql/postgresql.conf
- user: postgres
- group: postgres
- mode: 0600
- require:
- pkg: postgresql94-server
- cmd: postgresql-first-run-init
/var/lib/pgsql/9.4/data/pg_hba.conf:
file.managed:
- source: salt://postgresql/pg_hba.conf
- template: jinja
- user: postgres
- group: postgres
- mode: 0600
- require:
- pkg: postgresql94-server
- cmd: postgresql-first-run-init
dbuser:
postgres_user.present:
- name: {{ pillar['dbuser'] }}
- password: {{ pillar['dbpassword'] }}
- user: postgres
- superuser: True
- require:
- service: postgresql-9.4
dbname:
postgres_database.present:
- name: {{ pillar['dbname'] }}
- encoding: UTF8
- lc_ctype: en_US.UTF8
- lc_collate: en_US.UTF8
- template: template0
- owner: {{ pillar['dbuser'] }}
- user: postgres
- require:
- postgres_user: dbuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment