All Projects → express42 → postgresql_lwrp

express42 / postgresql_lwrp

Licence: MIT license
Express 42 postgresql cookbook

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
shell
77523 projects

Projects that are alternatives of or similar to postgresql lwrp

cookbook-redmine
Chef's Cookbook for installing Redmine
Stars: ✭ 25 (-56.14%)
Mutual labels:  chef, cookbooks
chef-icinga2
Icinga 2 Chef Cookbook
Stars: ✭ 42 (-26.32%)
Mutual labels:  chef, cookbooks
chef-drone
Chef cookbook for Drone
Stars: ✭ 23 (-59.65%)
Mutual labels:  chef, cookbooks
confluence
Development repository for the confluence cookbook
Stars: ✭ 42 (-26.32%)
Mutual labels:  chef
firewall
Development repository for the firewall cookbook
Stars: ✭ 97 (+70.18%)
Mutual labels:  chef
nustuff
Useful scripting and Linux configuration examples
Stars: ✭ 39 (-31.58%)
Mutual labels:  chef
chef-load
chef-load - a tool for simulating load on a Chef Infra Server and/or a Chef Automate server
Stars: ✭ 30 (-47.37%)
Mutual labels:  chef
chef
Chef-Server API client in golang
Stars: ✭ 78 (+36.84%)
Mutual labels:  chef
event bus postgres
🐘 Postgres event store for event_bus
Stars: ✭ 49 (-14.04%)
Mutual labels:  postgres
HandlebarsCookbook
A cookbook of handlebars and mustache, focus on handlebars.js , mustache.js and lightncandy usage
Stars: ✭ 20 (-64.91%)
Mutual labels:  cookbooks
line
Development repository for the line cookbook
Stars: ✭ 96 (+68.42%)
Mutual labels:  chef
COVID19-FeedbackApplication
A simple application is developed to get feedback from a user and analyzing the text to predict the sentiment.
Stars: ✭ 13 (-77.19%)
Mutual labels:  chef
ossec
Development repository for the ossec cookbook
Stars: ✭ 42 (-26.32%)
Mutual labels:  chef
challenges-chef
📖 Challenges Your Chef Skills By Solving Real Questions.
Stars: ✭ 27 (-52.63%)
Mutual labels:  chef
squid
Development repository for the squid cookbook
Stars: ✭ 27 (-52.63%)
Mutual labels:  chef
chef-postgres-hardening
This chef cookbook provides security configuration for PostgreSQL.
Stars: ✭ 26 (-54.39%)
Mutual labels:  chef
heltin
Robust client registry for individuals receiving mental healthcare services.
Stars: ✭ 18 (-68.42%)
Mutual labels:  postgres
chef-chrome
Chef cookbook to install Google Chrome browser
Stars: ✭ 16 (-71.93%)
Mutual labels:  chef
transmission
Development repository for the transmission cookbook
Stars: ✭ 14 (-75.44%)
Mutual labels:  chef
kitchen-vcenter
A test-kitchen driver for vCenter REST API
Stars: ✭ 23 (-59.65%)
Mutual labels:  chef

Chef cookbook Code Climate Build Status

Description

This cookbook includes recipes and providers to install and configure postgresql database. This cookbook was tested with Postgresql 9.1, 9.2, 9.3, 9.4, 9.5, 9.6 & 10.

Supported platforms:

  • Debian 8
  • Debian 9
  • Ubuntu 14.04
  • Ubuntu 16.04
  • Ubuntu 18.04

Note: TravisCI tests for Ubuntu 18.04 are omitted now because they somehow hang. Local Vagrant & Docker-based tests are succesfull. This will be investigated further.

Changelog

See CHANGELOG.md

Requirements

The minimal recommended version of chef-client is 13.0.113. It may still work on version 12.5.1 and older, but no tests are made starting from version 1.3.0 of this cookbook as Chef 12 is reaching its EOL in the April, 2018

Dependencies

  • apt
  • cron
  • poise-python

Attributes

This cookbook have server and client attribute files.

With client attributes(["postgresql"]["client"]) you can set only postgresql client and library version.

Server attributes are starting from ["postgresql"]["defaults"] and used as default attributes for postgresql provider. You should not override this defaults, you can pass your settings to provider instead.

Resources/Providers

Resource: default

Actions

  • :create: creates postgresql cluster

Resource parameters

  • cluster_name: name attribute. Cluster name (e.g. main). Be aware, systemd (in Ubuntu 16.04 and Debian Jessie) not working with cluster names that containing dashes ('-').
  • cluster_version: set cluster version
  • cookbook: cookbook for templates. Skip this for default templates.
  • cluster_create_options: options for pg_createcluster (only locale related options)
  • configuration: Hash with configuration options for postgresql, see examples.
  • hba_configuration: Array with hba configuration, see examples.
  • ident_configuration: Array with ident configuration, see examples.
  • replication: Hash with replication configuration. See replication example.
  • replication_initial_copy: Boolean. If true pg_basebackup will be exec to make initial replication copy. Default is false.
  • replication_start_slave: Boolean. If true slave cluster will be started after creation. Should be used with replication_initial_copy option. Default false.
  • allow_restart_cluster: Can be first, always or none. Specifies when cluster must restart instead of reload. first – only first time after installation. always – always restart, even if changes doesn't require restart. none - never, use reload every time. Default is none.

Other

Cloud backup helper:

postgresql_cloud_backup_helper.sh helper can be found at /opt/wal-e/bin/.

Usage:

postgresql_cloud_backup_helper.sh <cluster_name> <cluster_version> last|count

  • cluster_name – postgresql cluster name (ex. main)
  • cluser_version – postgresql cluser version (ex. 9.3)
  • last – shows last backup time
  • count – shows total number of backups.

Examples

Example master database setup:

postgresql 'main' do
  cluster_version '9.3'
  cluster_create_options( locale: 'ru_RU.UTF-8' )
  configuration(
      listen_addresses:           '192.168.0.2',
      max_connections:            300,
      ssl_renegotiation_limit:    0,
      shared_buffers:             '512MB',
      maintenance_work_mem:       '64MB',
      work_mem:                   '8MB',
      log_min_duration_statement: 200
  )
  hba_configuration(
    [
      { type: 'host', database: 'all', user: 'all', address: '192.168.0.0/24', method: 'md5' },
      { type: 'host', database: 'replication', user: 'postgres', address: '192.168.0.3/32', method: 'trust' }
    ]
  )
end

Example slave database setup:

postgresql 'main' do
   cluster_version '9.3'
  cluster_create_options( locale: 'ru_RU.UTF-8' )
  configuration(
      listen_addresses:           '192.168.0.3',
      max_connections:            300,
      ssl_renegotiation_limit:    0,
      shared_buffers:             '512MB',
      maintenance_work_mem:       '64MB',
      work_mem:                   '8MB',
      log_min_duration_statement: 200
  )
  hba_configuration(
    [
      { type: 'host', database: 'all', user: 'all', address: '192.168.0.0/24', method: 'md5' },
      { type: 'host', database: 'replication', user: 'postgres', address: '192.168.0.2/32', method: 'trust' }
    ]
  )
  replication(
    standby_mode: 'on',
    primary_conninfo: 'host=192.168.0.1',
    trigger_file: '/tmp/pgtrigger'
  )
  replication_initial_copy true
  replication_start_slave true
end

Example slave configuration with replication slots (PostgreSQL >= 9.4)

replication(
  standby_mode: 'on',
  primary_conninfo: 'host=192.168.0.1',
  trigger_file: '/tmp/pgtrigger'
  primary_slot_name: 'some_slot_on_master'
)

Don't forget to create slot on master server before:

# SELECT pg_create_physical_replication_slot('some_slot_on_master');

Example users and databases setup

postgresql_user 'user01' do
  in_version '9.3'
  in_cluster 'main'
  unencrypted_password 'user01password'
end

postgresql_database 'database01' do
  in_version '9.3'
  in_cluster 'main'
  owner 'user01'
end

Example full daily database backup

postgresql_cloud_backup 'main' do
  utility 'wal-g'
  in_version '9.3'
  in_cluster 'main'
  full_backup_time weekday: '*', month: '*', day: '*', hour: '3', minute: '0'
  # Data bag item should contain following keys for S3 protocol:
  # aws_access_key_id, aws_secret_access_key, wale_s3_prefix
  parameters Chef::EncryptedDataBagItem.load('s3', 'secrets').to_hash.select {|i| i != "id"}
  # Or just a hash, if you don't use data bags:
  parameters { aws_access_key_id: 'access_key', aws_secret_access_key: 'secret_key', walg_s3_prefix: 's3_prefix' }
  # In case you need to prepend wal-e with, for example, traffic limiter
  # you can use following method:
  command_prefix 'trickle -s -u 1024'
  # It will be prepended to resulting wal-e execution in cron task
end

Example usage of cloud backup helper usage

$ /opt/wal-e/bin/postgresql_cloud_backup_helper.sh main 9.3 last
1428192159
$ /opt/wal-e/bin/postgresql_cloud_backup_helper.sh main 9.3 count
31

Example of how to install extensions from postgresql-contrib NOTE: schema and version are optional parameters, but others are required

postgresql_extension 'cube' do
  in_version '9.4'
  in_cluster 'main'
  db 'test01'
  schema 'public'
end

Example of how to install extensions from http://pgxn.org/ NOTE: schema is an optional parameter, but others are required

pgxn_extension 'pg_lambda' do
  in_version '9.4'
  in_cluster 'main'
  db 'test01'
  version '1.0.2'
  stage 'stable'
end

License and Maintainer

Maintainer:: LLC Express 42 ([email protected]) Source:: https://github.com/express42/postgresql_lwrp Issues:: https://github.com/express42/postgresql_lwrp/issues

License:: MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].