<commit_before># chef-postgresql

## Description

Installs [PostgreSQL](http://www.postgresql.org), The world's most advanced open source database.

This installs postgres 9.x from the [PostgreSQL backports for stable Ubuntu releases](https://launchpad.net/~pitti/+archive/postgresql).

Currently supported versions:

* `9.0`
* `9.1`
* `9.2`

The default version is `9.2`.

## Requirements

### Supported Platforms

The following platforms are supported by this cookbook, meaning that the recipes run on these platforms without error:

* Ubuntu
* Debian 6


## Recipes

* `postgresql` - Set up the apt repository and install dependent packages
* `postgresql::client` - Front-end programs for PostgreSQL 9.x
* `postgresql::server` - Object-relational SQL database, version 9.x server
* `postgresql::contrib` - Additional facilities for PostgreSQL
* `postgresql::dbg` - Debug symbols for the server daemon
* `postgresql::doc` - Documentation for the PostgreSQL database management system
* `postgresql::libpq` - PostgreSQL C client library and header files for libpq5 (PostgreSQL library)
* `postgresql::postgis` - Geographic objects support for PostgreSQL 9.x


## Usage

This cookbook installs the postgresql components if not present, and pulls updates if they are installed on the system.

Additionally this cookbook provides three definitions to create, alter and delete users as well as create and drop databases or setup extensions. Usage is as follows:


```ruby
# create a user
pg_user "myuser" do
  privileges :superuser => false, :createdb => false, :login => true
  password "<PASSWORD>"
end

# create a user with an MD5-encrypted password
pg_user "myuser" do
  privileges :superuser => false, :createdb => false, :login => true
  encrypted_password "<PASSWORD>"
end

# drop a user
pg_user "myuser" do
  action :drop
end

# create a database
pg_database "mydb" do
  owner "myuser"
  encoding "utf8"
  template "template0"
  locale "en_US.UTF8"
end

# install extensions to database
pg_database_extensions "mydb" do
  languages "plpgsql"              # install `plpgsql` language - single value may be passed without array
  extensions ["hstore", "dblink"]  # install `hstore` and `dblink` extensions - multiple values in array
  postgis true                     # install `postgis` support
end

# drop dblink extension
pg_database_extensions "mydb" do
  action :drop
  extensions "dblink"
end

# drop a database
pg_database "mydb" do
  action :drop
end
```

Or add the user/database via attributes:

```ruby
:users => [
  {
    :username  => "dickeyxxx",
    :password  => "password",
    :superuser => true,
    :createdb  => true,
    :login     => true
  }
],

:databases => [
  {
    :name => "my_db",
    :owner  => "dickeyxxx",
    :template  => "template0",
    :encoding  => "utf8",
    :locale => "en_US.UTF8",
    :extensions => "hstore"
  }
]
```


## Attributes

```ruby
default["postgresql"]["version"]                         = "9.2"

default["postgresql"]["environment_variables"]           = {}
default["postgresql"]["pg_ctl_options"]                  = ""
default["postgresql"]["pg_hba"]                          = []
default["postgresql"]["pg_ident"]                        = []
default["postgresql"]["start"]                           = "auto"  # auto, manual, disabled

#------------------------------------------------------------------------------
# POSTGIS
#------------------------------------------------------------------------------
default["postgis"]["version"]                            = "1.5"

#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------
default["postgresql"]["data_directory"]                  = "/var/lib/postgresql/#{node["postgresql"]["version"]}/main"
default["postgresql"]["hba_file"]                        = "/etc/postgresql/#{node["postgresql"]["version"]}/main/pg_hba.conf"
default["postgresql"]["ident_file"]                      = "/etc/postgresql/#{node["postgresql"]["version"]}/main/pg_ident.conf"
default["postgresql"]["external_pid_file"]               = "/var/run/postgresql/#{node["postgresql"]["version"]}-main.pid"
<commit_msg>Added warning to README about version override<commit_after># chef-postgresql

## Description

Installs [PostgreSQL](http://www.postgresql.org), The world's most advanced open source database.

This installs postgres 9.x from the [PostgreSQL backports for stable Ubuntu releases](https://launchpad.net/~pitti/+archive/postgresql).

Currently supported versions:

* `9.0`
* `9.1`
* `9.2`

The default version is `9.2`.

## Requirements

### Supported Platforms

The following platforms are supported by this cookbook, meaning that the recipes run on these platforms without error:

* Ubuntu
* Debian 6


## Recipes

* `postgresql` - Set up the apt repository and install dependent packages
* `postgresql::client` - Front-end programs for PostgreSQL 9.x
* `postgresql::server` - Object-relational SQL database, version 9.x server
* `postgresql::contrib` - Additional facilities for PostgreSQL
* `postgresql::dbg` - Debug symbols for the server daemon
* `postgresql::doc` - Documentation for the PostgreSQL database management system
* `postgresql::libpq` - PostgreSQL C client library and header files for libpq5 (PostgreSQL library)
* `postgresql::postgis` - Geographic objects support for PostgreSQL 9.x


## Usage

This cookbook installs the postgresql components if not present, and pulls updates if they are installed on the system.

Additionally this cookbook provides three definitions to create, alter and delete users as well as create and drop databases or setup extensions. Usage is as follows:


```ruby
# create a user
pg_user "myuser" do
  privileges :superuser => false, :createdb => false, :login => true
  password "<PASSWORD>"
end

# create a user with an MD5-encrypted password
pg_user "myuser" do
  privileges :superuser => false, :createdb => false, :login => true
  encrypted_password "<PASSWORD>"
end

# drop a user
pg_user "myuser" do
  action :drop
end

# create a database
pg_database "mydb" do
  owner "myuser"
  encoding "utf8"
  template "template0"
  locale "en_US.UTF8"
end

# install extensions to database
pg_database_extensions "mydb" do
  languages "plpgsql"              # install `plpgsql` language - single value may be passed without array
  extensions ["hstore", "dblink"]  # install `hstore` and `dblink` extensions - multiple values in array
  postgis true                     # install `postgis` support
end

# drop dblink extension
pg_database_extensions "mydb" do
  action :drop
  extensions "dblink"
end

# drop a database
pg_database "mydb" do
  action :drop
end
```

Or add the user/database via attributes:

```ruby
:users => [
  {
    :username  => "dickeyxxx",
    :password  => "password",
    :superuser => true,
    :createdb  => true,
    :login     => true
  }
],

:databases => [
  {
    :name => "my_db",
    :owner  => "dickeyxxx",
    :template  => "template0",
    :encoding  => "utf8",
    :locale => "en_US.UTF8",
    :extensions => "hstore"
  }
]
```


## Attributes

```ruby
# WARNING: If this version number is changed in your own recipes, the
# FILE LOCATIONS (see below) attributes *must* also be overridden in
# order to re-compute the paths with the correct version number.
default["postgresql"]["version"]                         = "9.2"

default["postgresql"]["environment_variables"]           = {}
default["postgresql"]["pg_ctl_options"]                  = ""
default["postgresql"]["pg_hba"]                          = []
default["postgresql"]["pg_ident"]                        = []
default["postgresql"]["start"]                           = "auto"  # auto, manual, disabled

#------------------------------------------------------------------------------
# POSTGIS
#------------------------------------------------------------------------------
default["postgis"]["version"]                            = "1.5"

#------------------------------------------------------------------------------
# FILE LOCATIONS
#------------------------------------------------------------------------------
default["postgresql"]["data_directory"]                  = "/var/lib/postgresql/#{node["postgresql"]["version"]}/main"
default["postgresql"]["hba_file"]                        = "/etc/postgresql/#{node["postgresql"]["version"]}/main/pg_hba.conf"
default["postgresql"]["ident_file"]                      = "/etc/postgresql/#{node["postgresql"]["version"]}/main/pg_ident.conf"
default["postgresql"]["external_pid_file"]               = "/var/run/postgresql/#{node["postgresql"]["version"]}-main.pid"

{'fraction_non_alphanumeric': 0.1889899804215133, 'fraction_numerical': 0.005758378440631118, 'mean_word_length': 2.559016393442623, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6900644', 'n_tokens_mistral': 2509, 'n_tokens_neox': 2477, 'n_words': 724}