---
name: postgresql

templates:
  postgresql_ctl.erb: bin/postgresql_ctl
  postgresql.conf.erb: config/postgresql.conf
  pg_hba.conf.erb: config/pg_hba.conf

packages:
  - pid_utils
  - postgresql_9.3

provides:
- name: db
  type: postgresql
  properties:
  - bind_port
  - databases

properties:
  bind_ip:
    description: |
      IP address on which the PostgresSQL server will listen.
    default: 0.0.0.0

  bind_port:
    description: |
      Port on which the PostgresSQL server will listen.
    default: 5432

  databases:
    description: |
      List of databases to create, along with a role name and password of a role
      to create for the database.
    example:
    - name: my-database
      role: my-db-role
      password: my-db-password
    - name: my-other-database
      role: my-other-db-role
      password: my-other-db-password

  max_connections:
    description: |
      Maximum number of open database connections to support.
    default: 500

  shared_buffers:
    description: |
      The amount of memory the database server uses for shared memory buffers.
      Larger settings for shared_buffers usually require a corresponding
      increase in checkpoint_segments, in order to spread out the process of
      writing large quantities of new or changed data over a longer period of
      time.
    default: 1GB

  checkpoint_segments:
    description: |
      Maximum number of log file segments between automatic WAL
      checkpoints. Increasing this parameter can increase the amount of time
      needed for crash recovery.
    default: 10

  log_min_messages:
    description: |
      Controls which message levels are written to the server log.
      Valid values are DEBUG5, DEBUG4, DEBUG3, DEBUG2, DEBUG1, INFO, NOTICE,
      WARNING, ERROR, LOG, FATAL, and PANIC. Each level includes all the levels
      that follow it. The later the level, the fewer messages are sent to the
      log.
    default: LOG

  log_min_duration_statement:
    description: |
      Causes the duration of each completed statement to be logged if the
      statement ran for at least the specified number of milliseconds.
      Setting this to zero prints all statement durations. Minus-one
      (the default) disables logging statement durations.
    default: -1
