用于 PostgreSQL 组件的主厨手册
Installs PostgreSQL, The world's most advanced open source database.
This installs postgres 9.x from the PostgreSQL Apt Repository.
Currently supported versions:
9.09.19.29.39.4The default version is 9.4.
The following platforms are supported by this cookbook, meaning that the recipes run on these platforms without error:
This cookbook requires Chef >= 11.13 due to the use of the sensitive attribute for some resources.
postgresql - Set up the apt repository and install dependent packagespostgresql::apt_repository - Internal recipe to setup the apt repositorypostgresql::client - Front-end programs for PostgreSQL 9.xpostgresql::configuration - Internal recipe to manage configuration filespostgresql::contrib - Additional facilities for PostgreSQLpostgresql::data_directory - Internal recipe to setup the data directorypostgresql::dbg - Debug symbols for the server daemonpostgresql::debian_backports - Internal recipe to manage debian backportspostgresql::doc - Documentation for the PostgreSQL database management systempostgresql::libpq - PostgreSQL C client library and header files for libpq5 (PostgreSQL library)postgresql::postgis - Geographic objects support for PostgreSQL 9.x (currently Ubuntu only)postgresql::server - Object-relational SQL database, version 9.x serverpostgresql::server_dev - Development files for PostgreSQL server-side programmingpostgresql::service - Internal recipe to declare the system servicepostgresql::setup_databases - Internal recipe to manage specified databasespostgresql::setup_extensions - Internal recipe to manage specified database extensionspostgresql::setup_languages - Internal recipe to manage specified database languagespostgresql::setup_users - Internal recipe to manage specified usersThis cookbook installs the postgresql components if not present, and pulls updates if they are installed on the system.
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:
# create a user
postgresql_user "myuser" do
superuser false
createdb false
login true
replication false
password "mypassword"
end
# create a user with an MD5-encrypted password
postgresql_user "myuser" do
superuser false
createdb false
login true
replication false
encrypted_password "667ff118ef6d196c96313aeaee7da519"
end
# drop a user
postgresql_user "myuser" do
action :drop
endOr add users via attributes:
"postgresql": {
"users": [
{
"username": "dickeyxxx",
"password": "password",
"superuser": true,
"replication": false,
"createdb": true,
"createrole": false,
"inherit": true,
"replication": false,
"login": true
}
]
}# create a database
postgresql_database "mydb" do
owner "myuser"
encoding "UTF-8"
template "template0"
locale "en_US.UTF-8"
end
# install extensions to database
postgresql_extension "hstore" do
database "mydb"
end
postgresql_language "plpgsql" do
database "mydb"
end
# drop dblink extension
postgresql_extension "dblink" do
database "mydb"
action :drop
end
# drop a database
postgresql_database "mydb" do
action :drop
endOr add the database via attributes:
"postgresql": {
"databases": [
{
"name": "my_db",
"owner": "dickeyxxx",
"template": "template0",
"encoding": "UTF-8",
"locale": "en_US.UTF-8",
"extensions": ["hstore", "dblink"],
"postgis": true
}
]
}The postgresql.conf configuration may be set one of two ways:
To create a custom configuration, set the node["postgresql"]["conf"] hash with your custom settings:
"postgresql": {
"conf": {
"data_directory": "/dev/null",
// ... all options explicitly set here
}
}You may also set the contents of pg_hba.conf via attributes:
…Currently the APT distributions are sourced from http://apt.postgresql.org/pub/repos/apt/. In some cases this source might not immediately contain a package for the distribution of your target system.
The node["postgresql"]["apt_distribution"] attribute can be used to install PostgreSQL from a different compatible
distribution:
"postgresql": {
"apt_distribution": "precise"
}…postgresql-{version}-ip4r
postgresql-{version}-pgq3
postgresql-{version}-pgmp
postgresql-{version}-plproxy
postgresql-{version}-repmgr
postgresql-{version}-debversion
postgresql-{version}-pgpool2
postgresql-{version}-slony1-2git checkout -b my-new-feature)git commit -am 'Added some feature')git push origin my-new-feature)Many thanks go to the following who have contributed to making this cookbook even better:
pg_user and pg_database definitionsencrypted_password param for pg_user definitionpg_database_extensions definitionpostgresql.confpostgresql.conf ssl parameter failure on 9.1pg_user definitionpostgresql.confpostgresql.confwal_writer_delay attributeencrypted_password in the pg_user recipecommit_delay and temp_buffers settingsrandom_page_cost and seq_page_cost settingsdefault["postgresql"]["apt_key"] to new locationlog_filename attributepg_database definitionpg_user definitionpg_user definitionssl_ca_file and ssl_crl_file attributes to the configuration templateservice_actions attributechef-postgresql
暂无开放 Issues,或尚未同步最近议题。