from-scratch 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Berksfile.lock +11 -0
- data/chefignore +1 -0
- data/cookbooks/apt/CHANGELOG.md +248 -0
- data/cookbooks/apt/README.md +294 -0
- data/cookbooks/apt/attributes/default.rb +51 -0
- data/cookbooks/apt/files/default/15update-stamp +1 -0
- data/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
- data/cookbooks/apt/libraries/helpers.rb +61 -0
- data/cookbooks/apt/libraries/matchers.rb +17 -0
- data/cookbooks/apt/libraries/network.rb +31 -0
- data/cookbooks/apt/metadata.json +1 -0
- data/cookbooks/apt/providers/preference.rb +84 -0
- data/cookbooks/apt/providers/repository.rb +246 -0
- data/cookbooks/apt/recipes/cacher-client.rb +83 -0
- data/cookbooks/apt/recipes/cacher-ng.rb +43 -0
- data/cookbooks/apt/recipes/default.rb +112 -0
- data/cookbooks/apt/recipes/unattended-upgrades.rb +47 -0
- data/cookbooks/apt/resources/preference.rb +37 -0
- data/cookbooks/apt/resources/repository.rb +60 -0
- data/cookbooks/apt/templates/debian-6.0/acng.conf.erb +173 -0
- data/cookbooks/apt/templates/default/01proxy.erb +9 -0
- data/cookbooks/apt/templates/default/10recommends.erb +3 -0
- data/cookbooks/apt/templates/default/20auto-upgrades.erb +2 -0
- data/cookbooks/apt/templates/default/50unattended-upgrades.erb +68 -0
- data/cookbooks/apt/templates/default/acng.conf.erb +275 -0
- data/cookbooks/apt/templates/default/unattended-upgrades.seed.erb +1 -0
- data/cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +269 -0
- data/cookbooks/build-essential/CHANGELOG.md +136 -0
- data/cookbooks/build-essential/README.md +108 -0
- data/cookbooks/build-essential/attributes/default.rb +20 -0
- data/cookbooks/build-essential/libraries/matchers.rb +5 -0
- data/cookbooks/build-essential/libraries/timing.rb +124 -0
- data/cookbooks/build-essential/libraries/xcode_command_line_tools.rb +210 -0
- data/cookbooks/build-essential/metadata.json +1 -0
- data/cookbooks/build-essential/recipes/_debian.rb +28 -0
- data/cookbooks/build-essential/recipes/_fedora.rb +32 -0
- data/cookbooks/build-essential/recipes/_freebsd.rb +24 -0
- data/cookbooks/build-essential/recipes/_mac_os_x.rb +22 -0
- data/cookbooks/build-essential/recipes/_omnios.rb +33 -0
- data/cookbooks/build-essential/recipes/_rhel.rb +36 -0
- data/cookbooks/build-essential/recipes/_smartos.rb +27 -0
- data/cookbooks/build-essential/recipes/_solaris2.rb +48 -0
- data/cookbooks/build-essential/recipes/_suse.rb +29 -0
- data/cookbooks/build-essential/recipes/default.rb +29 -0
- data/cookbooks/chef-sugar/CHANGELOG.md +159 -0
- data/cookbooks/chef-sugar/README.md +464 -0
- data/cookbooks/chef-sugar/metadata.json +1 -0
- data/cookbooks/chef-sugar/recipes/default.rb +34 -0
- data/cookbooks/openssl/CHANGELOG.md +30 -0
- data/cookbooks/openssl/README.md +115 -0
- data/cookbooks/openssl/attributes/default.rb +21 -0
- data/cookbooks/openssl/libraries/secure_password.rb +37 -0
- data/cookbooks/openssl/metadata.json +31 -0
- data/cookbooks/openssl/providers/x509.rb +94 -0
- data/cookbooks/openssl/recipes/default.rb +18 -0
- data/cookbooks/openssl/recipes/upgrade.rb +39 -0
- data/cookbooks/openssl/resources/x509.rb +16 -0
- data/cookbooks/postgresql/CHANGELOG.md +220 -0
- data/cookbooks/postgresql/README.md +464 -0
- data/cookbooks/postgresql/attributes/default.rb +549 -0
- data/cookbooks/postgresql/files/default/tests/minitest/apt_pgdg_postgresql_test.rb +39 -0
- data/cookbooks/postgresql/files/default/tests/minitest/default_test.rb +27 -0
- data/cookbooks/postgresql/files/default/tests/minitest/ruby_test.rb +28 -0
- data/cookbooks/postgresql/files/default/tests/minitest/server_test.rb +43 -0
- data/cookbooks/postgresql/files/default/tests/minitest/support/helpers.rb +29 -0
- data/cookbooks/postgresql/libraries/default.rb +377 -0
- data/cookbooks/postgresql/metadata.json +56 -0
- data/cookbooks/postgresql/recipes/apt_pgdg_postgresql.rb +18 -0
- data/cookbooks/postgresql/recipes/client.rb +32 -0
- data/cookbooks/postgresql/recipes/config_initdb.rb +148 -0
- data/cookbooks/postgresql/recipes/config_pgtune.rb +284 -0
- data/cookbooks/postgresql/recipes/contrib.rb +44 -0
- data/cookbooks/postgresql/recipes/default.rb +18 -0
- data/cookbooks/postgresql/recipes/ruby.rb +117 -0
- data/cookbooks/postgresql/recipes/server.rb +89 -0
- data/cookbooks/postgresql/recipes/server_conf.rb +34 -0
- data/cookbooks/postgresql/recipes/server_debian.rb +38 -0
- data/cookbooks/postgresql/recipes/server_redhat.rb +100 -0
- data/cookbooks/postgresql/recipes/yum_pgdg_postgresql.rb +45 -0
- data/cookbooks/postgresql/templates/default/pg_hba.conf.erb +35 -0
- data/cookbooks/postgresql/templates/default/pgsql.sysconfig.erb +4 -0
- data/cookbooks/postgresql/templates/default/postgresql.conf.erb +21 -0
- data/cookbooks/scratchify/.chef/knife.rb +2 -5
- data/cookbooks/scratchify/Berksfile +2 -1
- data/cookbooks/scratchify/Berksfile.lock +11 -0
- data/cookbooks/scratchify/README.md +34 -17
- data/cookbooks/scratchify/bin/scratchify +1 -1
- data/cookbooks/scratchify/chefignore +1 -0
- data/cookbooks/scratchify/from-scratch.gemspec +2 -5
- data/cookbooks/scratchify/lib/from-scratch.rb +25 -0
- data/cookbooks/scratchify/lib/{from/scratch → from-scratch}/version.rb +1 -1
- data/cookbooks/scratchify/metadata.json +2 -1
- data/cookbooks/scratchify/templates/node.json.erb +34 -0
- data/cookbooks/scratchify/templates/user.json.erb +6 -0
- data/lib/from-scratch.rb +2 -2
- data/lib/from-scratch/version.rb +1 -1
- data/templates/node.json.erb +6 -3
- metadata +85 -10
- data/cookbooks/scratchify/bin/console +0 -14
- data/cookbooks/scratchify/bin/setup +0 -7
- data/cookbooks/scratchify/data_bags/users/deploy.json +0 -6
- data/cookbooks/scratchify/environments/.gitkeep +0 -0
- data/cookbooks/scratchify/lib/from/scratch.rb +0 -31
- data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +0 -35
- data/cookbooks/scratchify/nodes/normfood.ru.json +0 -75
- data/cookbooks/scratchify/roles/.gitkeep +0 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
{
|
2
|
+
"name": "postgresql",
|
3
|
+
"description": "Installs and configures postgresql for clients or servers",
|
4
|
+
"long_description": "Description\n===========\n\nInstalls and configures PostgreSQL as a client or a server.\n\nRequirements\n============\n\n## Platforms\n\n* Debian, Ubuntu\n* Red Hat/CentOS/Scientific (6.0+ required) - \"EL6-family\"\n* Fedora\n* SUSE\n\nTested on:\n\n* Ubuntu 10.04, 11.10, 12.04, 14.04, 14.10\n* Red Hat 6.1, Scientific 6.1, CentOS 6.3\n\n## Cookbooks\n\nRequires Opscode's `openssl` cookbook for secure password generation.\n\nRequires a C compiler and development headers in order to build the\n`pg` RubyGem to provide Ruby bindings in the `ruby` recipe.\n\nOpscode's `build-essential` cookbook provides this functionality on\nDebian, Ubuntu, and EL6-family.\n\nWhile not required, Opscode's `database` cookbook contains resources\nand providers that can interact with a PostgreSQL database. This\ncookbook is a dependency of database.\n\nAttributes\n==========\n\nThe following attributes are set based on the platform, see the\n`attributes/default.rb` file for default values.\n\n* `node['postgresql']['version']` - version of postgresql to manage\n* `node['postgresql']['dir']` - home directory of where postgresql\n data and configuration lives.\n\n* `node['postgresql']['client']['packages']` - An array of package names\n that should be installed on \"client\" systems.\n* `node['postgresql']['server']['packages']` - An array of package names\n that should be installed on \"server\" systems.\n* `node['postgresql']['server']['config_change_notify']` - Type of\n notification triggered when a config file changes.\n* `node['postgresql']['contrib']['packages']` - An array of package names\n that could be installed on \"server\" systems for useful sysadmin tools.\n\n* `node['postgresql']['enable_pgdg_apt']` - Whether to enable the apt repo\n by the PostgreSQL Global Development Group, which contains newer versions\n of PostgreSQL.\n\n* `node['postgresql']['enable_pgdg_yum']` - Whether to enable the yum repo\n by the PostgreSQL Global Development Group, which contains newer versions\n of PostgreSQL.\n\n* `node['postgresql']['initdb_locale']` - Sets the default locale for the\n database cluster. If this attribute is not specified, the locale is\n inherited from the environment that initdb runs in. Sometimes you must\n have a system locale that is not what you want for your database cluster,\n and this attribute addresses that scenario. Valid only for EL-family\n distros (RedHat/Centos/etc.).\n\nThe following attributes are generated in\n`recipe[postgresql::server]`.\n\n* `node['postgresql']['password']['postgres']` - randomly generated\n password by the `openssl` cookbook's library.\n (TODO: This is broken, as it disables the password.)\n\nConfiguration\n-------------\n\nThe `postgresql.conf` and `pg_hba.conf` files are dynamically\ngenerated from attributes. Each key in `node['postgresql']['config']`\nis a postgresql configuration directive, and will be rendered in the\nconfig file. For example, the attribute:\n\n node['postgresql']['config']['listen_addresses'] = 'localhost'\n\nWill result in the following line in the `postgresql.conf` file:\n\n listen_addresses = 'localhost'\n\nThe attributes file contains default values for Debian and RHEL\nplatform families (per the `node['platform_family']`). These defaults\nhave disparity between the platforms because they were originally\nextracted from the postgresql.conf files in the previous version of\nthis cookbook, which differed in their default config. The resulting\nconfiguration files will be the same as before, but the content will\nbe dynamically rendered from the attributes. The helpful commentary\nwill no longer be present. You should consult the PostgreSQL\ndocumentation for specific configuration details.\n\nSee __Recipes__ `config_initdb` and `config_pgtune` below to\nauto-generate many postgresql.conf settings.\n\nFor values that are \"on\" or \"off\", they should be specified as literal\n`true` or `false`. String values will be used with single quotes. Any\nconfiguration option set to the literal `nil` will be skipped\nentirely. All other values (e.g., numeric literals) will be used as\nis. So for example:\n\n node.default['postgresql']['config']['logging_collector'] = true\n node.default['postgresql']['config']['datestyle'] = 'iso, mdy'\n node.default['postgresql']['config']['ident_file'] = nil\n node.default['postgresql']['config']['port'] = 5432\n\nWill result in the following config lines:\n\n logging_collector = 'on'\n datestyle = 'iso,mdy'\n port = 5432\n\n(no line printed for `ident_file` as it is `nil`)\n\nNote that the `unix_socket_directory` configuration was renamed to\n`unix_socket_directories` in Postgres 9.3 so make sure to use the\n`node['postgresql']['unix_socket_directories']` attribute instead of\n`node['postgresql']['unix_socket_directory']`.\n\nThe `pg_hba.conf` file is dynamically generated from the\n`node['postgresql']['pg_hba']` attribute. This attribute must be an\narray of hashes, each hash containing the authorization data. As it is\nan array, you can append to it in your own recipes. The hash keys in\nthe array must be symbols. Each hash will be written as a line in\n`pg_hba.conf`. For example, this entry from\n`node['postgresql']['pg_hba']`:\n\n [{:comment => '# Optional comment',\n :type => 'local', :db => 'all', :user => 'postgres', :addr => nil, :method => 'md5'}]\n\nWill result in the following line in `pg_hba.conf`:\n\n # Optional comment\n local all postgres md5\n\nUse `nil` if the CIDR-ADDRESS should be empty (as above).\nDon't provide a comment if none is desired in the `pg_hba.conf` file.\n\nNote that the following authorization rule is supplied automatically by\nthe cookbook template. The cookbook needs this to execute SQL in the\nPostgreSQL server without supplying the clear-text password (which isn't\nknown by the cookbook). Therefore, your `node['postgresql']['pg_hba']`\nattributes don't need to specify this authorization rule:\n\n # \"local\" is for Unix domain socket connections only\n local all all ident\n\n(By the way, the template uses `peer` instead of `ident` for PostgreSQL-9.1\nand above, which has the same effect.)\n\nRecipes\n=======\n\ndefault\n-------\n\nIncludes the client recipe.\n\nclient\n------\n\nInstalls the packages defined in the\n`node['postgresql']['client']['packages']` attribute.\n\nruby\n----\n\n**NOTE** This recipe may not currently work when installing Chef with\n the\n [\"Omnibus\" full stack installer](http://opscode.com/chef/install) on\n some platforms due to an incompatibility with OpenSSL. See\n [COOK-1406](http://tickets.opscode.com/browse/COOK-1406). You can\n build from source into the Chef omnibus installation to work around\n this issue.\n\nInstall the `pg` gem under Chef's Ruby environment so it can be used\nin other recipes. The build-essential packages and postgresql client\npackages will be installed during the compile phase, so that the\nnative extensions of `pg` can be compiled.\n\nserver\n------\n\nIncludes the `server_debian` or `server_redhat` recipe to get the\nappropriate server packages installed and service managed. Also\nmanages the configuration for the server:\n\n* generates a strong default password (via `openssl`) for `postgres`\n (TODO: This is broken, as it disables the password.)\n* sets the password for postgres\n* manages the `postgresql.conf` file.\n* manages the `pg_hba.conf` file.\n\nserver\\_debian\n--------------\n\nInstalls the postgresql server packages and sets up the service. You\nshould include the `postgresql::server` recipe, which will include\nthis on Debian platforms.\n\nserver\\_redhat\n--------------\n\nManages the postgres user and group (with UID/GID 26, per RHEL package\nconventions), installs the postgresql server packages, initializes the\ndatabase, and manages the postgresql service. You should include the\n`postgresql::server` recipe, which will include this on RHEL/Fedora\nplatforms.\n\nconfig\\_initdb\n--------------\n\nTakes locale and timezone settings from the system configuration.\nThis recipe creates `node.default['postgresql']['config']` attributes\nthat conform to the system's locale and timezone. In addition, this\nrecipe creates the same error reporting and logging settings that\n`initdb` provided: a rotation of 7 days of log files named\npostgresql-Mon.log, etc.\n\nThe default attributes created by this recipe are easy to override with\nnormal attributes because of Chef attribute precedence. For example,\nsuppose a DBA wanted to keep log files indefinitely, rolling over daily\nor when growing to 10MB. The Chef installation could include the\n`postgresql::config_initdb` recipe for the locale and timezone settings,\nbut customize the logging settings with these node JSON attributes:\n\n \"postgresql\": {\n \"config\": {\n \"log_rotation_age\": \"1d\",\n \"log_rotation_size\": \"10MB\",\n \"log_filename\": \"postgresql-%Y-%m-%d_%H%M%S.log\"\n }\n }\n\nCredits: This `postgresql::config_initdb` recipe is based on algorithms\nin the [source code](http://doxygen.postgresql.org/initdb_8c_source.html)\nfor the PostgreSQL `initdb` utility.\n\nconfig\\_pgtune\n--------------\n\nPerformance tuning.\nTakes the wimpy default postgresql.conf and expands the database server\nto be as powerful as the hardware it's being deployed on. This recipe\ncreates a baseline configuration of `node.default['postgresql']['config']`\nattributes in the right general range for a dedicated Postgresql system.\nMost installations won't need additional performance tuning.\n\nThe only decision you need to make is to choose a `db_type` from the\nfollowing database workloads. (See the recipe code comments for more\ndetailed descriptions.)\n\n * \"dw\" -- Data Warehouse\n * \"oltp\" -- Online Transaction Processing\n * \"web\" -- Web Application\n * \"mixed\" -- Mixed DW and OLTP characteristics\n * \"desktop\" -- Not a dedicated database\n\nThis recipe uses a performance model with three input parameters.\nThese node attributes are completely optional, but it is obviously\nimportant to choose the `db_type` correctly:\n\n * `node['postgresql']['config_pgtune']['db_type']` --\n Specifies database type from the list of five choices above.\n If not specified, the default is \"mixed\".\n\n * `node['postgresql']['config_pgtune']['max_connections']` --\n Specifies maximum number of connections expected.\n If not specified, it depends on database type:\n \"web\":200, \"oltp\":300, \"dw\":20, \"mixed\":80, \"desktop\":5\n\n * `node['postgresql']['config_pgtune']['total_memory']` --\n Specifies total system memory in kB. (E.g., \"49416564kB\".)\n If not specified, it will be taken from Ohai automatic attributes.\n This could be used to tune a system that isn't a dedicated database.\n\nThe default attributes created by this recipe are easy to override with\nnormal attributes because of Chef attribute precedence. For example, if\nyou are running application benchmarks to try different buffer cache\nsizes, you would experiment with this node JSON attribute:\n\n \"postgresql\": {\n \"config\": {\n \"shared_buffers\": \"3GB\"\n }\n }\n\nNote that the recipe uses `max_connections` in its computations. If\nyou want to override that setting, you should specify\n`node['postgresql']['config_pgtune']['max_connections']` instead of\n`node['postgresql']['config']['max_connections']`.\n\nCredits: This `postgresql::config_pgtune` recipe is based on the\n[pgtune python script](https://github.com/gregs1104/pgtune)\ndeveloped by\n[Greg Smith](http://notemagnet.blogspot.com/2008/11/automating-initial-postgresqlconf.html)\nand\n[other pgsql-hackers](http://www.postgresql.org/message-id/491C6CDC.8090506@agliodbs.com).\n\ncontrib\n-------\n\nInstalls the packages defined in the\n`node['postgresql']['contrib']['packages']` attribute. The contrib\ndirectory of the PostgreSQL distribution includes porting tools,\nanalysis utilities, and plug-in features that database engineers often\nrequire. Some (like `pgbench`) are executable. Others (like\n`pg_buffercache`) would need to be installed into the database.\n\nAlso installs any contrib module extensions defined in the\n`node['postgresql']['contrib']['extensions']` attribute. These will be\navailable in any subsequently created databases in the cluster, because\nthey will be installed into the `template1` database using the\n`CREATE EXTENSION` command. For example, it is often necessary/helpful\nfor problem troubleshooting and maintenance planning to install the\nviews and functions in these [standard instrumentation extensions]\n(http://www.postgresql.org/message-id/flat/4DC32600.6080900@pgexperts.com#4DD3D6C6.5060006@2ndquadrant.com):\n\n node['postgresql']['contrib']['extensions'] = [\n \"pageinspect\",\n \"pg_buffercache\",\n \"pg_freespacemap\",\n \"pgrowlocks\",\n \"pg_stat_statements\",\n \"pgstattuple\"\n ]\n\nNote that the `pg_stat_statements` view only works if `postgresql.conf`\nloads its shared library, which can be done with this node attribute:\n\n node['postgresql']['config']['shared_preload_libraries'] = 'pg_stat_statements'\n\nIf using `shared_preload_libraries` in combination with the `contrib` recipe,\nmake sure that the `contrib` recipe is called before the `server` recipe (to\nensure the dependencies are installed and setup in order).\n\napt\\_pgdg\\_postgresql\n----------------------\n\nEnables the PostgreSQL Global Development Group yum repository\nmaintained by Devrim Gündüz for updated PostgreSQL packages.\n(The PGDG is the groups that develops PostgreSQL.)\nAutomatically included if the `node['postgresql']['enable_pgdg_apt']`\nattribute is true. Also set the\n`node['postgresql']['client']['packages']` and\n`node['postgresql']['server]['packages']` to the list of packages to\nuse from this repository, and set the `node['postgresql']['version']`\nattribute to the version to use (e.g., \"9.2\").\n\nyum\\_pgdg\\_postgresql\n---------------------\n\nEnables the PostgreSQL Global Development Group yum repository\nmaintained by Devrim Gündüz for updated PostgreSQL packages.\n(The PGDG is the groups that develops PostgreSQL.)\nAutomatically included if the `node['postgresql']['enable_pgdg_yum']`\nattribute is true. Also use `override_attributes` to set a number of\nvalues that will need to have embedded version numbers. For example:\n\n node['postgresql']['enable_pgdg_yum'] = true\n node['postgresql']['version'] = \"9.2\"\n node['postgresql']['dir'] = \"/var/lib/pgsql/9.2/data\"\n node['postgresql']['config']['data_directory'] = node['postgresql']['dir']\n node['postgresql']['client']['packages'] = [\"postgresql92\", \"postgresql92-devel\"]\n node['postgresql']['server']['packages'] = [\"postgresql92-server\"]\n node['postgresql']['server']['service_name'] = \"postgresql-9.2\"\n node['postgresql']['contrib']['packages'] = [\"postgresql92-contrib\"]\n\nYou may set `node['postgresql']['pgdg']['repo_rpm_url']` attributes\nto pick up recent [PGDG repo packages](http://yum.postgresql.org/repopackages.php).\n\nResources/Providers\n===================\n\nSee the [database](http://community.opscode.com/cookbooks/database)\nfor resources and providers that can be used for managing PostgreSQL\nusers and databases.\n\nUsage\n=====\n\nOn systems that need to connect to a PostgreSQL database, add to a run\nlist `recipe[postgresql]` or `recipe[postgresql::client]`.\n\nOn systems that should be PostgreSQL servers, use\n`recipe[postgresql::server]` on a run list. This recipe does set a\npassword for the `postgres` user.\nIf you're using `chef server`, if the attribute\n`node['postgresql']['password']['postgres']` is not found,\nthe recipe generates a random password and performs a node.save.\n(TODO: This is broken, as it disables the password.)\nIf you're using `chef-solo`, you'll need\nto set the attribute `node['postgresql']['password']['postgres']` in\nyour node's `json_attribs` file or in a role.\n\nOn Debian family systems, SSL will be enabled, as the packages on\nDebian/Ubuntu also generate the SSL certificates. If you use another\nplatform and wish to use SSL in postgresql, then generate your SSL\ncertificates and distribute them in your own cookbook, and set the\n`node['postgresql']['config']['ssl']` attribute to true in your\nrole/cookboook/node.\n\nOn server systems, the postgres server is restarted when a configuration\nfile changes. This can be changed to reload only by setting the\nfollowing attribute:\n\n node['postgresql']['server']['config_change_notify'] = :reload\n\nChef Solo Note\n==============\n\nThe following node attribute is stored on the Chef Server when using\n`chef-client`. Because `chef-solo` does not connect to a server or\nsave the node object at all, to have the password persist across\n`chef-solo` runs, you must specify them in the `json_attribs` file\nused. For Example:\n\n {\n \"postgresql\": {\n \"password\": {\n \"postgres\": \"iloverandompasswordsbutthiswilldo\"\n }\n },\n \"run_list\": [\"recipe[postgresql::server]\"]\n }\n\nThat should actually be the \"encrypted password\" instead of cleartext,\nso you should generate it as an md5 hash using the PostgreSQL algorithm.\n\n* You could copy the md5-hashed password from an existing postgres\ndatabase if you have `postgres` access and want to use the same password:<br>\n`select * from pg_shadow where usename='postgres';`\n* You can run this from any postgres database session to use a new password:<br>\n`select 'md5'||md5('iloverandompasswordsbutthiswilldo'||'postgres');`\n* You can run this from a linux commandline:<br>\n`echo -n 'iloverandompasswordsbutthiswilldo''postgres' | openssl md5 | sed -e 's/.* /md5/'`\n\nLicense and Author\n==================\n\n- Author:: Joshua Timberman (<joshua@opscode.com>)\n- Author:: Lamont Granquist (<lamont@opscode.com>)\n- Author:: Chris Roberts (<chrisroberts.code@gmail.com>)\n- Author:: David Crane (<davidc@donorschoose.org>)\n- Author:: Aaron Baer (<aaron@hw-ops.com>)\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
|
5
|
+
"maintainer": "Heavy Water Operations, LLC",
|
6
|
+
"maintainer_email": "support@hw-ops.com",
|
7
|
+
"license": "Apache 2.0",
|
8
|
+
"platforms": {
|
9
|
+
"ubuntu": "< 14.10",
|
10
|
+
"debian": ">= 0.0.0",
|
11
|
+
"fedora": ">= 0.0.0",
|
12
|
+
"suse": ">= 0.0.0",
|
13
|
+
"amazon": ">= 0.0.0",
|
14
|
+
"redhat": "~> 6.0",
|
15
|
+
"centos": "~> 6.0",
|
16
|
+
"scientific": "~> 6.0",
|
17
|
+
"oracle": "~> 6.0"
|
18
|
+
},
|
19
|
+
"dependencies": {
|
20
|
+
"apt": ">= 1.9.0",
|
21
|
+
"build-essential": ">= 0.0.0",
|
22
|
+
"openssl": "~> 4.0.0"
|
23
|
+
},
|
24
|
+
"recommendations": {
|
25
|
+
|
26
|
+
},
|
27
|
+
"suggestions": {
|
28
|
+
|
29
|
+
},
|
30
|
+
"conflicting": {
|
31
|
+
|
32
|
+
},
|
33
|
+
"providing": {
|
34
|
+
|
35
|
+
},
|
36
|
+
"replacing": {
|
37
|
+
|
38
|
+
},
|
39
|
+
"attributes": {
|
40
|
+
|
41
|
+
},
|
42
|
+
"groupings": {
|
43
|
+
|
44
|
+
},
|
45
|
+
"recipes": {
|
46
|
+
"postgresql": "Includes postgresql::client",
|
47
|
+
"postgresql::ruby": "Installs pg gem for Ruby bindings",
|
48
|
+
"postgresql::client": "Installs postgresql client package(s)",
|
49
|
+
"postgresql::server": "Installs postgresql server packages, templates",
|
50
|
+
"postgresql::server_redhat": "Installs postgresql server packages, redhat family style",
|
51
|
+
"postgresql::server_debian": "Installs postgresql server packages, debian family style"
|
52
|
+
},
|
53
|
+
"version": "3.4.20",
|
54
|
+
"source_url": "",
|
55
|
+
"issues_url": ""
|
56
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
if not %w(jessie squeeze wheezy sid lucid precise saucy trusty utopic).include? node['postgresql']['pgdg']['release_apt_codename']
|
2
|
+
raise "Not supported release by PGDG apt repository"
|
3
|
+
end
|
4
|
+
|
5
|
+
include_recipe 'apt'
|
6
|
+
|
7
|
+
file "remove deprecated Pitti PPA apt repository" do
|
8
|
+
action :delete
|
9
|
+
path "/etc/apt/sources.list.d/pitti-postgresql-ppa"
|
10
|
+
end
|
11
|
+
|
12
|
+
apt_repository 'apt.postgresql.org' do
|
13
|
+
uri 'http://apt.postgresql.org/pub/repos/apt'
|
14
|
+
distribution "#{node['postgresql']['pgdg']['release_apt_codename']}-pgdg"
|
15
|
+
components ['main', node['postgresql']['version']]
|
16
|
+
key 'https://www.postgresql.org/media/keys/ACCC4CF8.asc'
|
17
|
+
action :add
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: postgresql
|
3
|
+
# Recipe:: client
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
#
|
17
|
+
|
18
|
+
if platform_family?('debian') && node['postgresql']['version'].to_f > 9.3
|
19
|
+
node.default['postgresql']['enable_pgdg_apt'] = true
|
20
|
+
end
|
21
|
+
|
22
|
+
if(node['postgresql']['enable_pgdg_apt']) and platform_family?('debian')
|
23
|
+
include_recipe 'postgresql::apt_pgdg_postgresql'
|
24
|
+
end
|
25
|
+
|
26
|
+
if(node['postgresql']['enable_pgdg_yum']) and platform_family?('rhel')
|
27
|
+
include_recipe 'postgresql::yum_pgdg_postgresql'
|
28
|
+
end
|
29
|
+
|
30
|
+
node['postgresql']['client']['packages'].each do |pg_pack|
|
31
|
+
package pg_pack
|
32
|
+
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: postgresql
|
3
|
+
# Recipe:: config_initdb
|
4
|
+
# Author:: David Crane (<davidc@donorschoose.org>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
#######
|
20
|
+
# Load the locale_date_order() and select_default_timezone(tzdir)
|
21
|
+
# methods from libraries/default.rb
|
22
|
+
::Chef::Recipe.send(:include, Opscode::PostgresqlHelpers)
|
23
|
+
|
24
|
+
#######
|
25
|
+
# This recipe is derived from the setup_config() source code in the
|
26
|
+
# PostgreSQL initdb utility. It determines postgresql.conf settings that
|
27
|
+
# conform to the system's locale and timezone configuration, and also
|
28
|
+
# sets the error reporting and logging settings.
|
29
|
+
#
|
30
|
+
# See http://doxygen.postgresql.org/initdb_8c_source.html for the
|
31
|
+
# original initdb source code.
|
32
|
+
#
|
33
|
+
# By examining the system configuration, this recipe will set the
|
34
|
+
# following node.default['postgresql']['config'] attributes:
|
35
|
+
#
|
36
|
+
# - Locale and Formatting -
|
37
|
+
# * datestyle
|
38
|
+
# * lc_messages
|
39
|
+
# * lc_monetary
|
40
|
+
# * lc_numeric
|
41
|
+
# * lc_time
|
42
|
+
# * default_text_search_config
|
43
|
+
#
|
44
|
+
# - Timezone Conversion -
|
45
|
+
# * log_timezone
|
46
|
+
# * timezone
|
47
|
+
#
|
48
|
+
# In addition, this recipe will recommend the same error reporting and
|
49
|
+
# logging settings that initdb provided. These settings do differ from
|
50
|
+
# the PostgreSQL default settings, which would log to stderr only. The
|
51
|
+
# initdb settings rotate 7 days of log files named postgresql-Mon.log,
|
52
|
+
# etc. through these node.default['postgresql']['config'] attributes:
|
53
|
+
#
|
54
|
+
# - Where to Log -
|
55
|
+
# * log_destination = 'stderr'
|
56
|
+
# * log_directory = 'pg_log'
|
57
|
+
# * log_filename = 'postgresql-%a.log'
|
58
|
+
# (Default was: postgresql-%Y-%m-%d_%H%M%S.log)
|
59
|
+
# * logging_collector = true # on
|
60
|
+
# (Turned on to capture stderr logging and redirect into log files)
|
61
|
+
# (Default was: false # off)
|
62
|
+
# * log_rotation_age = 1d
|
63
|
+
# * log_rotation_size = 0
|
64
|
+
# (Default was: 10MB)
|
65
|
+
# * log_truncate_on_rotation = true # on
|
66
|
+
# (Default was: false # off)
|
67
|
+
|
68
|
+
#######
|
69
|
+
# Locale Configuration
|
70
|
+
|
71
|
+
# See libraries/default.rb for the locale_date_order() method.
|
72
|
+
node.default['postgresql']['config']['datestyle'] = "iso, #{locale_date_order()}"
|
73
|
+
|
74
|
+
# According to the locale(1) manpage, the locale settings are determined
|
75
|
+
# by environment variables according to the following precedence:
|
76
|
+
# LC_ALL > (LC_MESSAGES, LC_MONETARY, LC_NUMERIC, LC_TIME) > LANG.
|
77
|
+
|
78
|
+
node.default['postgresql']['config']['lc_messages'] =
|
79
|
+
[ ENV['LC_ALL'], ENV['LC_MESSAGES'], ENV['LANG'] ].compact.first
|
80
|
+
|
81
|
+
node.default['postgresql']['config']['lc_monetary'] =
|
82
|
+
[ ENV['LC_ALL'], ENV['LC_MONETARY'], ENV['LANG'] ].compact.first
|
83
|
+
|
84
|
+
node.default['postgresql']['config']['lc_numeric'] =
|
85
|
+
[ ENV['LC_ALL'], ENV['LC_NUMERIC'], ENV['LANG'] ].compact.first
|
86
|
+
|
87
|
+
node.default['postgresql']['config']['lc_time'] =
|
88
|
+
[ ENV['LC_ALL'], ENV['LC_TIME'], ENV['LANG'] ].compact.first
|
89
|
+
|
90
|
+
node.default['postgresql']['config']['default_text_search_config'] =
|
91
|
+
case ENV['LANG']
|
92
|
+
when /da_.*/
|
93
|
+
'pg_catalog.danish'
|
94
|
+
when /nl_.*/
|
95
|
+
'pg_catalog.dutch'
|
96
|
+
when /en_.*/
|
97
|
+
'pg_catalog.english'
|
98
|
+
when /fi_.*/
|
99
|
+
'pg_catalog.finnish'
|
100
|
+
when /fr_.*/
|
101
|
+
'pg_catalog.french'
|
102
|
+
when /de_.*/
|
103
|
+
'pg_catalog.german'
|
104
|
+
when /hu_.*/
|
105
|
+
'pg_catalog.hungarian'
|
106
|
+
when /it_.*/
|
107
|
+
'pg_catalog.italian'
|
108
|
+
when /no_.*/
|
109
|
+
'pg_catalog.norwegian'
|
110
|
+
when /pt_.*/
|
111
|
+
'pg_catalog.portuguese'
|
112
|
+
when /ro_.*/
|
113
|
+
'pg_catalog.romanian'
|
114
|
+
when /ru_.*/
|
115
|
+
'pg_catalog.russian'
|
116
|
+
when /es_.*/
|
117
|
+
'pg_catalog.spanish'
|
118
|
+
when /sv_.*/
|
119
|
+
'pg_catalog.swedish'
|
120
|
+
when /tr_.*/
|
121
|
+
'pg_catalog.turkish'
|
122
|
+
else
|
123
|
+
nil
|
124
|
+
end
|
125
|
+
|
126
|
+
#######
|
127
|
+
# Timezone Configuration
|
128
|
+
|
129
|
+
# Determine the name of the system's default timezone and specify node
|
130
|
+
# defaults for the postgresql.cof settings. If the timezone cannot be
|
131
|
+
# identified, do as initdb would do: leave it unspecified so PostgreSQL
|
132
|
+
# uses it's internal default of GMT.
|
133
|
+
tzdirpath = pg_TZDIR() # See libraries/default.rb
|
134
|
+
default_timezone = select_default_timezone(tzdirpath) # See libraries/default.rb
|
135
|
+
if !default_timezone.nil?
|
136
|
+
node.default['postgresql']['config']['log_timezone'] = default_timezone
|
137
|
+
node.default['postgresql']['config']['timezone'] = default_timezone
|
138
|
+
end
|
139
|
+
|
140
|
+
#######
|
141
|
+
# - Where to Log -
|
142
|
+
node.default['postgresql']['config']['log_destination'] = 'stderr'
|
143
|
+
node.default['postgresql']['config']['log_directory'] = 'pg_log'
|
144
|
+
node.default['postgresql']['config']['log_filename'] = 'postgresql-%a.log'
|
145
|
+
node.default['postgresql']['config']['logging_collector'] = true # on
|
146
|
+
node.default['postgresql']['config']['log_rotation_age'] = '1d'
|
147
|
+
node.default['postgresql']['config']['log_rotation_size'] = 0
|
148
|
+
node.default['postgresql']['config']['log_truncate_on_rotation'] = true # on
|
@@ -0,0 +1,284 @@
|
|
1
|
+
#
|
2
|
+
# Cookbook Name:: postgresql
|
3
|
+
# Recipe:: config_pgtune
|
4
|
+
# Author:: David Crane (<davidc@donorschoose.org>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
#######
|
20
|
+
# Load the binaryround(value) method from libraries/default.rb
|
21
|
+
::Chef::Recipe.send(:include, Opscode::PostgresqlHelpers)
|
22
|
+
|
23
|
+
#######
|
24
|
+
# This recipe is based on Greg Smith's pgtune script (the Feb 1, 2012
|
25
|
+
# version at https://github.com/gregs1104/pgtune). Introduction: pgtune
|
26
|
+
# takes the wimpy default postgresql.conf and expands the database
|
27
|
+
# server to be as powerful as the hardware it's being deployed on.
|
28
|
+
#
|
29
|
+
# The default postgresql.conf aims at a system with approximately 128MB
|
30
|
+
# of RAM. This recipe recommends a baseline configuration in the right
|
31
|
+
# general range for a dedicated Postgresql system.
|
32
|
+
#
|
33
|
+
# This recipe takes three optional parameters that may be passed in as
|
34
|
+
# node['postgresql']['config_pgtune'] attributes:
|
35
|
+
# * db_type -- Specifies database type as one of: dw, oltp,
|
36
|
+
# web, mixed, desktop. If not specified, the default is mixed.
|
37
|
+
# * max_connections -- Specifies number of maximum connections
|
38
|
+
# expected. If not specified, it depends on database type.
|
39
|
+
# * total_memory -- Specifies total system memory. If not specified,
|
40
|
+
# it will be detected from the Ohai automatic attributes.
|
41
|
+
#
|
42
|
+
# Using those inputs, this recipe will compute and set the following
|
43
|
+
# node.default['postgresql']['config'] attributes:
|
44
|
+
# * max_connections
|
45
|
+
# * shared_buffers
|
46
|
+
# * effective_cache_size
|
47
|
+
# * work_mem
|
48
|
+
# * maintenance_work_mem
|
49
|
+
# * checkpoint_segments
|
50
|
+
# * checkpoint_completion_target
|
51
|
+
# * wal_buffers
|
52
|
+
# * default_statistics_target
|
53
|
+
#
|
54
|
+
# This recipe deviates from the original pgtune script for 2 settings:
|
55
|
+
# shared_buffers is capped for large memory systems (which Greg
|
56
|
+
# mentioned in a TODO.rst) and wal_buffers will auto-tune starting with
|
57
|
+
# 9.1 (which is a feature that Greg built into Postgresql).
|
58
|
+
|
59
|
+
#######
|
60
|
+
# These are the workload characteristics of the five database types
|
61
|
+
# that can be specified as node['postgresql']['config_pgtune']['db_type']:
|
62
|
+
#
|
63
|
+
# dw -- Data Warehouse
|
64
|
+
# * Typically I/O- or RAM-bound
|
65
|
+
# * Large bulk loads of data
|
66
|
+
# * Large complex reporting queries
|
67
|
+
# * Also called "Decision Support" or "Business Intelligence"
|
68
|
+
#
|
69
|
+
# oltp -- Online Transaction Processing
|
70
|
+
# * Typically CPU- or I/O-bound
|
71
|
+
# * DB slightly larger than RAM to 1TB
|
72
|
+
# * 20-40% small data write queries
|
73
|
+
# * Some long transactions and complex read queries
|
74
|
+
#
|
75
|
+
# web -- Web Application
|
76
|
+
# * Typically CPU-bound
|
77
|
+
# * DB much smaller than RAM
|
78
|
+
# * 90% or more simple queries
|
79
|
+
#
|
80
|
+
# mixed -- Mixed DW and OLTP characteristics
|
81
|
+
# * A wide mixture of queries
|
82
|
+
#
|
83
|
+
# desktop -- Not a dedicated database
|
84
|
+
# * A general workstation, perhaps for a developer
|
85
|
+
|
86
|
+
# Parse out db_type option, or use default.
|
87
|
+
db_type = 'mixed'
|
88
|
+
|
89
|
+
if (node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('db_type'))
|
90
|
+
db_type = node['postgresql']['config_pgtune']['db_type']
|
91
|
+
if (!(["dw","oltp","web","mixed","desktop"].include?(db_type)))
|
92
|
+
Chef::Log.fatal([
|
93
|
+
"Bad value (#{db_type})",
|
94
|
+
"for node['postgresql']['config_pgtune']['db_type'] attribute.",
|
95
|
+
"Valid values are one of dw, oltp, web, mixed, desktop."
|
96
|
+
].join(' '))
|
97
|
+
raise
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Parse out max_connections option, or use a value based on db_type.
|
102
|
+
con =
|
103
|
+
{ "web" => 200,
|
104
|
+
"oltp" => 300,
|
105
|
+
"dw" => 20,
|
106
|
+
"mixed" => 80,
|
107
|
+
"desktop" => 5
|
108
|
+
}.fetch(db_type)
|
109
|
+
|
110
|
+
if (node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('max_connections'))
|
111
|
+
max_connections = node['postgresql']['config_pgtune']['max_connections'].to_i
|
112
|
+
if max_connections <= 0
|
113
|
+
Chef::Log.fatal([
|
114
|
+
"Bad value (#{max_connections})",
|
115
|
+
"for node['postgresql']['config_pgtune']['max_connections'] attribute.",
|
116
|
+
"Valid values are non-zero integers only."
|
117
|
+
].join(' '))
|
118
|
+
raise
|
119
|
+
end
|
120
|
+
con = max_connections
|
121
|
+
end
|
122
|
+
|
123
|
+
# Parse out total_memory option, or use value detected by Ohai.
|
124
|
+
total_memory = node['memory']['total']
|
125
|
+
|
126
|
+
# Override max_connections with a node attribute if DevOps desires.
|
127
|
+
# For example, on a system *not* dedicated to Postgresql.
|
128
|
+
if (node['postgresql'].attribute?('config_pgtune') && node['postgresql']['config_pgtune'].attribute?('total_memory'))
|
129
|
+
total_memory = node['postgresql']['config_pgtune']['total_memory']
|
130
|
+
if (total_memory.match(/\A[1-9]\d*kB\Z/) == nil)
|
131
|
+
Chef::Application.fatal!([
|
132
|
+
"Bad value (#{total_memory})",
|
133
|
+
"for node['postgresql']['config_pgtune']['total_memory'] attribute.",
|
134
|
+
"Valid values are non-zero integers followed by kB (e.g., 49416564kB)."
|
135
|
+
].join(' '))
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Ohai reports node[:memory][:total] in kB, as in "921756kB"
|
140
|
+
mem = total_memory.split("kB")[0].to_i / 1024 # in MB
|
141
|
+
|
142
|
+
#######
|
143
|
+
# RAM-related settings computed as in Greg Smith's pgtune script.
|
144
|
+
# Remember that con and mem were either chosen above based on the
|
145
|
+
# db_type or the actual total memory, or were passed in attributes.
|
146
|
+
|
147
|
+
# (1) max_connections
|
148
|
+
# Sets the maximum number of concurrent connections.
|
149
|
+
node.default['postgresql']['config']['max_connections'] = con
|
150
|
+
|
151
|
+
# The calculations for the next four settings would not be optimal
|
152
|
+
# for low memory systems. In that case, the calculation is skipped,
|
153
|
+
# leaving the built-in Postgresql settings, which are actually
|
154
|
+
# intended for those low memory systems.
|
155
|
+
if (mem >= 256)
|
156
|
+
|
157
|
+
# (2) shared_buffers
|
158
|
+
# Sets the number of shared memory buffers used by the server.
|
159
|
+
shared_buffers =
|
160
|
+
{ "web" => mem/4,
|
161
|
+
"oltp" => mem/4,
|
162
|
+
"dw" => mem/4,
|
163
|
+
"mixed" => mem/4,
|
164
|
+
"desktop" => mem/16
|
165
|
+
}.fetch(db_type)
|
166
|
+
|
167
|
+
# Robert Haas has advised to cap the size of shared_buffers based on
|
168
|
+
# the memory architecture: 2GB on 32-bit and 8GB on 64-bit machines.
|
169
|
+
# http://rhaas.blogspot.com/2012/03/tuning-sharedbuffers-and-walbuffers.html
|
170
|
+
case node['kernel']['machine']
|
171
|
+
when "i386" # 32-bit machines
|
172
|
+
if shared_buffers > 2*1024
|
173
|
+
shared_buffers = 2*1024
|
174
|
+
end
|
175
|
+
when "x86_64" # 64-bit machines
|
176
|
+
if shared_buffers > 8*1024
|
177
|
+
shared_buffers = 8*1024
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
node.default['postgresql']['config']['shared_buffers'] = binaryround(shared_buffers*1024*1024)
|
182
|
+
|
183
|
+
# (3) effective_cache_size
|
184
|
+
# Sets the planner's assumption about the size of the disk cache.
|
185
|
+
# That is, the portion of the kernel's disk cache that will be
|
186
|
+
# used for PostgreSQL data files.
|
187
|
+
effective_cache_size =
|
188
|
+
{ "web" => mem * 3 / 4,
|
189
|
+
"oltp" => mem * 3 / 4,
|
190
|
+
"dw" => mem * 3 / 4,
|
191
|
+
"mixed" => mem * 3 / 4,
|
192
|
+
"desktop" => mem / 4
|
193
|
+
}.fetch(db_type)
|
194
|
+
|
195
|
+
node.default['postgresql']['config']['effective_cache_size'] = binaryround(effective_cache_size*1024*1024)
|
196
|
+
|
197
|
+
# (4) work_mem
|
198
|
+
# Sets the maximum memory to be used for query workspaces.
|
199
|
+
mem_con_v = (mem.to_f / con).ceil
|
200
|
+
|
201
|
+
work_mem =
|
202
|
+
{ "web" => mem_con_v,
|
203
|
+
"oltp" => mem_con_v,
|
204
|
+
"dw" => mem_con_v / 2,
|
205
|
+
"mixed" => mem_con_v / 2,
|
206
|
+
"desktop" => mem_con_v / 6
|
207
|
+
}.fetch(db_type)
|
208
|
+
|
209
|
+
node.default['postgresql']['config']['work_mem'] = binaryround(work_mem*1024*1024)
|
210
|
+
|
211
|
+
# (5) maintenance_work_mem
|
212
|
+
# Sets the maximum memory to be used for maintenance operations.
|
213
|
+
# This includes operations such as VACUUM and CREATE INDEX.
|
214
|
+
maintenance_work_mem =
|
215
|
+
{ "web" => mem / 16,
|
216
|
+
"oltp" => mem / 16,
|
217
|
+
"dw" => mem / 8,
|
218
|
+
"mixed" => mem / 16,
|
219
|
+
"desktop" => mem / 16
|
220
|
+
}.fetch(db_type)
|
221
|
+
|
222
|
+
# Cap maintenence RAM at 1GB on servers with lots of memory
|
223
|
+
if (maintenance_work_mem > 1*1024)
|
224
|
+
maintenance_work_mem = 1*1024
|
225
|
+
end
|
226
|
+
|
227
|
+
node.default['postgresql']['config']['maintenance_work_mem'] = binaryround(maintenance_work_mem*1024*1024)
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
#######
|
232
|
+
# Checkpoint-related parameters that affect transaction rate and
|
233
|
+
# maximum tolerable recovery playback time.
|
234
|
+
|
235
|
+
# (6) checkpoint_segments
|
236
|
+
# Sets the maximum distance in log segments between automatic WAL checkpoints.
|
237
|
+
checkpoint_segments =
|
238
|
+
{ "web" => 8,
|
239
|
+
"oltp" => 16,
|
240
|
+
"dw" => 64,
|
241
|
+
"mixed" => 16,
|
242
|
+
"desktop" => 3
|
243
|
+
}.fetch(db_type)
|
244
|
+
|
245
|
+
node.default['postgresql']['config']['checkpoint_segments'] = checkpoint_segments
|
246
|
+
|
247
|
+
# (7) checkpoint_completion_target
|
248
|
+
# Time spent flushing dirty buffers during checkpoint, as fraction
|
249
|
+
# of checkpoint interval.
|
250
|
+
checkpoint_completion_target =
|
251
|
+
{ "web" => "0.7",
|
252
|
+
"oltp" => "0.9",
|
253
|
+
"dw" => "0.9",
|
254
|
+
"mixed" => "0.9",
|
255
|
+
"desktop" => "0.5"
|
256
|
+
}.fetch(db_type)
|
257
|
+
|
258
|
+
node.default['postgresql']['config']['checkpoint_completion_target'] = checkpoint_completion_target
|
259
|
+
|
260
|
+
# (8) wal_buffers
|
261
|
+
# Sets the number of disk-page buffers in shared memory for WAL.
|
262
|
+
# Starting with 9.1, wal_buffers will auto-tune if set to the -1 default.
|
263
|
+
# For 8.X and 9.0, it needed to be specified, which pgtune did as follows.
|
264
|
+
if node['postgresql']['version'].to_f < 9.1
|
265
|
+
wal_buffers = 512 * checkpoint_segments
|
266
|
+
# The pgtune seems to use 1kB units for wal_buffers
|
267
|
+
node.default['postgresql']['config']['wal_buffers'] = binaryround(wal_buffers*1024)
|
268
|
+
else
|
269
|
+
node.default['postgresql']['config']['wal_buffers'] = "-1"
|
270
|
+
end
|
271
|
+
|
272
|
+
# (9) default_statistics_target
|
273
|
+
# Sets the default statistics target. This applies to table columns
|
274
|
+
# that have not had a column-specific target set via
|
275
|
+
# ALTER TABLE SET STATISTICS.
|
276
|
+
default_statistics_target =
|
277
|
+
{ "web" => 100,
|
278
|
+
"oltp" => 100,
|
279
|
+
"dw" => 500,
|
280
|
+
"mixed" => 100,
|
281
|
+
"desktop" => 100
|
282
|
+
}.fetch(db_type)
|
283
|
+
|
284
|
+
node.default['postgresql']['config']['default_statistics_target'] = default_statistics_target
|