Skip to content

Instantly share code, notes, and snippets.

@billfehring
Last active December 22, 2015 16:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billfehring/3f15e050415e1615ccb7 to your computer and use it in GitHub Desktop.
Save billfehring/3f15e050415e1615ccb7 to your computer and use it in GitHub Desktop.
# temp start postgres
from subprocess import Popen
def init_and_start_db():
cmd_str = '/usr/local/etc/rc.d/postgresql initdb && /usr/local/etc/rc.d/postgresql start'
proc = Popen([cmd_str], shell=True,
stdin=None, stdout=None, stderr=None, close_fds=True)
return cmd_str
postgres-server-pkg:
pkg.installed:
- name: postgresql-server
/etc/rc.conf:
file.append:
- text:
- postgresql_enable="YES"
- postgresql_data="/zpath/db"
- postgresql_flags="-m fast"
- postgresql_initdb_flags="--encoding=utf-8 --lc-collate=C"
- postgresql_class="default"
- postgresql_profiles=""
- require_in:
- service: postgresql
- cmd: init_postgres_db
init_postgres_db:
cmd.call:
- name: bsdpg
- func: init_and_start_db
- unless: stat /zpath/db/postgresql.conf
- require:
- pkg: postgres-server-pkg
- require_in:
- service: postgresql
postgresql:
service:
- running
- sig: postgres
- require:
- pkg: postgres-server-pkg
include:
- zpath.postgres.database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment