default['postgresql']['defaults']['server']['version'] = '9.2'

default['postgresql']['defaults']['server']['configuration'] = {
  listen_addresses: 'localhost',
  port: 5432,
  max_connections: 100,
  shared_buffers: '100MB',
  temp_buffers: '8MB',
  max_prepared_transactions: 0,
  work_mem: '2MB',
  maintenance_work_mem: '64MB',
  max_stack_depth: '2MB',
  max_files_per_process: '1000',
  vacuum_cost_delay: 0,
  wal_level: 'hot_standby',
  fsync: 'on',
  synchronous_commit: 'on',
  checkpoint_segments: '64',
  wal_sync_method: 'fsync',
  checkpoint_completion_target: '0.9',
  effective_cache_size: "#{(node['memory']['total'].to_i / (2 * 1024))}MB",
  log_destination: 'stderr',
  syslog_ident: 'postgres',
  log_min_duration_statement: 200,
  log_truncate_on_rotation: 'on',
  log_rotation_age: '1d',
  log_rotation_size: 0,
  log_line_prefix: '%t [%p]: [%l-1]',
  track_activities: 'on',
  track_counts: 'on',
  autovacuum: 'on',
  autovacuum_naptime: '1min',
  archive_mode: 'off',
  max_wal_senders: 5,
  wal_keep_segments: 32,
  hot_standby: 'off',
  max_standby_archive_delay: '30s',
  max_standby_streaming_delay: '30s',
  wal_receiver_status_interval: '10s',
  hot_standby_feedback: 'on',
  extra_float_digits: 0,
  client_encoding: 'UTF8',
  ssl: true,
  ssl_cert_file: '/etc/ssl/certs/ssl-cert-snakeoil.pem',
  ssl_key_file: '/etc/ssl/private/ssl-cert-snakeoil.key',
  ssl_renegotiation_limit: 0,
  lc_messages: 'en_US.UTF-8',
  lc_monetary: 'en_US.UTF-8',
  lc_numeric: 'en_US.UTF-8',
  lc_time: 'en_US.UTF-8',
  default_text_search_config: 'pg_catalog.russian',
}
default['postgresql']['defaults']['server']['ident_configuration'] = []

default['postgresql']['defaults']['server']['hba_configuration'] = [
  { type: 'local', database: 'all', user: 'postgres', address: '',        method: 'peer' },
  { type: 'local', database: 'all', user: 'all', address: '',             method: 'peer' },
  { type: 'host',  database: 'all', user: 'all', address: '127.0.0.1/32', method: 'md5'  },
  { type: 'host',  database: 'all', user: 'all', address: '::1/128',      method: 'md5'  },
]
default['postgresql']['defaults']['server']['replication'] = {}
