server_maint 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +21 -0
- data/lib/cookbooks/aws/CHANGELOG.md +11 -0
- data/lib/cookbooks/aws/CONTRIBUTING +29 -0
- data/lib/cookbooks/aws/LICENSE +201 -0
- data/lib/cookbooks/aws/README.md +271 -0
- data/lib/cookbooks/aws/attributes/default.rb +20 -0
- data/lib/cookbooks/aws/libraries/ec2.rb +58 -0
- data/lib/cookbooks/aws/metadata.rb +7 -0
- data/lib/cookbooks/aws/providers/ebs_volume.rb +236 -0
- data/lib/cookbooks/aws/providers/elastic_ip.rb +90 -0
- data/lib/cookbooks/aws/providers/elastic_lb.rb +24 -0
- data/lib/cookbooks/aws/providers/resource_tag.rb +93 -0
- data/lib/cookbooks/aws/recipes/default.rb +25 -0
- data/lib/cookbooks/aws/resources/ebs_volume.rb +17 -0
- data/lib/cookbooks/aws/resources/elastic_ip.rb +11 -0
- data/lib/cookbooks/aws/resources/elastic_lb.rb +10 -0
- data/lib/cookbooks/aws/resources/resource_tag.rb +11 -0
- data/lib/cookbooks/database/.gitignore +1 -0
- data/lib/cookbooks/database/CHANGELOG.md +51 -0
- data/lib/cookbooks/database/CONTRIBUTING +29 -0
- data/lib/cookbooks/database/LICENSE +201 -0
- data/lib/cookbooks/database/README.md +468 -0
- data/lib/cookbooks/database/libraries/provider_database_mysql.rb +103 -0
- data/lib/cookbooks/database/libraries/provider_database_mysql_user.rb +76 -0
- data/lib/cookbooks/database/libraries/provider_database_postgresql.rb +131 -0
- data/lib/cookbooks/database/libraries/provider_database_postgresql_user.rb +83 -0
- data/lib/cookbooks/database/libraries/provider_database_sql_server.rb +109 -0
- data/lib/cookbooks/database/libraries/provider_database_sql_server_user.rb +106 -0
- data/lib/cookbooks/database/libraries/resource_database.rb +119 -0
- data/lib/cookbooks/database/libraries/resource_database_user.rb +90 -0
- data/lib/cookbooks/database/libraries/resource_mysql_database.rb +34 -0
- data/lib/cookbooks/database/libraries/resource_mysql_database_user.rb +34 -0
- data/lib/cookbooks/database/libraries/resource_postgresql_database.rb +35 -0
- data/lib/cookbooks/database/libraries/resource_postgresql_database_user.rb +35 -0
- data/lib/cookbooks/database/libraries/resource_sql_server_database.rb +34 -0
- data/lib/cookbooks/database/libraries/resource_sql_server_database_user.rb +34 -0
- data/lib/cookbooks/database/metadata.rb +22 -0
- data/lib/cookbooks/database/recipes/default.rb +20 -0
- data/lib/cookbooks/database/recipes/ebs_backup.rb +89 -0
- data/lib/cookbooks/database/recipes/ebs_volume.rb +204 -0
- data/lib/cookbooks/database/recipes/master.rb +78 -0
- data/lib/cookbooks/database/recipes/mysql.rb +20 -0
- data/lib/cookbooks/database/recipes/postgresql.rb +20 -0
- data/lib/cookbooks/database/recipes/snapshot.rb +62 -0
- data/lib/cookbooks/database/templates/default/app_grants.sql.erb +8 -0
- data/lib/cookbooks/database/templates/default/aws_config.erb +3 -0
- data/lib/cookbooks/database/templates/default/chef-solo-database-snapshot.cron.erb +6 -0
- data/lib/cookbooks/database/templates/default/chef-solo-database-snapshot.json.erb +1 -0
- data/lib/cookbooks/database/templates/default/chef-solo-database-snapshot.rb.erb +6 -0
- data/lib/cookbooks/database/templates/default/ebs-backup-cron.erb +2 -0
- data/lib/cookbooks/database/templates/default/ebs-db-backup.sh.erb +8 -0
- data/lib/cookbooks/database/templates/default/ebs-db-restore.sh.erb +10 -0
- data/lib/cookbooks/database/templates/default/s3cfg.erb +27 -0
- data/lib/cookbooks/mysql/.gitignore +5 -0
- data/lib/cookbooks/mysql/CHANGELOG.md +86 -0
- data/lib/cookbooks/mysql/CONTRIBUTING +29 -0
- data/lib/cookbooks/mysql/Gemfile +8 -0
- data/lib/cookbooks/mysql/LICENSE +201 -0
- data/lib/cookbooks/mysql/README.md +227 -0
- data/lib/cookbooks/mysql/attributes/client.rb +50 -0
- data/lib/cookbooks/mysql/attributes/server.rb +153 -0
- data/lib/cookbooks/mysql/files/default/tests/minitest/server_test.rb +36 -0
- data/lib/cookbooks/mysql/files/default/tests/minitest/support/helpers.rb +11 -0
- data/lib/cookbooks/mysql/libraries/helpers.rb +33 -0
- data/lib/cookbooks/mysql/metadata.rb +140 -0
- data/lib/cookbooks/mysql/recipes/client.rb +59 -0
- data/lib/cookbooks/mysql/recipes/default.rb +20 -0
- data/lib/cookbooks/mysql/recipes/ruby.rb +36 -0
- data/lib/cookbooks/mysql/recipes/server.rb +216 -0
- data/lib/cookbooks/mysql/recipes/server_ec2.rb +51 -0
- data/lib/cookbooks/mysql/templates/default/debian.cnf.erb +12 -0
- data/lib/cookbooks/mysql/templates/default/grants.sql.erb +15 -0
- data/lib/cookbooks/mysql/templates/default/my.cnf.erb +211 -0
- data/lib/cookbooks/mysql/templates/default/mysql-server.seed.erb +10 -0
- data/lib/cookbooks/mysql/templates/default/port_mysql.erb +3 -0
- data/lib/cookbooks/mysql/templates/windows/my.cnf.erb +61 -0
- data/lib/cookbooks/mysql/test/features/query_database.feature +26 -0
- data/lib/cookbooks/mysql/test/features/step_definitions/mysql_steps.rb +47 -0
- data/lib/cookbooks/mysql/test/features/support/env.rb +3 -0
- data/lib/cookbooks/mysql/test/features/support/mysql_helpers.rb +51 -0
- data/lib/cookbooks/mysql/test/kitchen/Kitchenfile +5 -0
- data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/.gitignore +1 -0
- data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/README.md +63 -0
- data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/attributes/default.rb +27 -0
- data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/metadata.rb +10 -0
- data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/recipes/client.rb +20 -0
- data/lib/cookbooks/mysql/test/kitchen/cookbooks/mysql_test/recipes/server.rb +72 -0
- data/lib/cookbooks/openssl/CHANGELOG.md +0 -0
- data/lib/cookbooks/openssl/CONTRIBUTING +29 -0
- data/lib/cookbooks/openssl/LICENSE +201 -0
- data/lib/cookbooks/openssl/README.md +37 -0
- data/lib/cookbooks/openssl/libraries/secure_password.rb +37 -0
- data/lib/cookbooks/openssl/metadata.rb +8 -0
- data/lib/cookbooks/openssl/recipes/default.rb +19 -0
- data/lib/cookbooks/postgresql/CHANGELOG.md +35 -0
- data/lib/cookbooks/postgresql/CONTRIBUTING +29 -0
- data/lib/cookbooks/postgresql/LICENSE +201 -0
- data/lib/cookbooks/postgresql/README.md +148 -0
- data/lib/cookbooks/postgresql/attributes/default.rb +103 -0
- data/lib/cookbooks/postgresql/metadata.rb +21 -0
- data/lib/cookbooks/postgresql/recipes/client.rb +26 -0
- data/lib/cookbooks/postgresql/recipes/default.rb +20 -0
- data/lib/cookbooks/postgresql/recipes/ruby.rb +40 -0
- data/lib/cookbooks/postgresql/recipes/server.rb +64 -0
- data/lib/cookbooks/postgresql/recipes/server_debian.rb +64 -0
- data/lib/cookbooks/postgresql/recipes/server_redhat.rb +77 -0
- data/lib/cookbooks/postgresql/templates/default/debian.postgresql.conf.erb +499 -0
- data/lib/cookbooks/postgresql/templates/default/pg_hba.conf.erb +83 -0
- data/lib/cookbooks/postgresql/templates/default/redhat.postgresql.conf.erb +501 -0
- data/lib/cookbooks/sqlite/.gitignore +4 -0
- data/lib/cookbooks/sqlite/CHANGELOG.md +3 -0
- data/lib/cookbooks/sqlite/CONTRIBUTING +29 -0
- data/lib/cookbooks/sqlite/Gemfile +2 -0
- data/lib/cookbooks/sqlite/LICENSE +201 -0
- data/lib/cookbooks/sqlite/README.md +36 -0
- data/lib/cookbooks/sqlite/metadata.rb +12 -0
- data/lib/cookbooks/sqlite/recipes/default.rb +30 -0
- data/lib/cookbooks/sqlite/test/kitchen/Kitchenfile +1 -0
- data/lib/cookbooks/xfs/CHANGELOG.md +0 -0
- data/lib/cookbooks/xfs/CONTRIBUTING +29 -0
- data/lib/cookbooks/xfs/LICENSE +201 -0
- data/lib/cookbooks/xfs/README.md +30 -0
- data/lib/cookbooks/xfs/metadata.rb +12 -0
- data/lib/cookbooks/xfs/recipes/default.rb +26 -0
- data/lib/server_maint/version.rb +1 -1
- metadata +127 -4
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Description
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Installs and configures PostgreSQL as a client or a server.
|
|
5
|
+
|
|
6
|
+
Requirements
|
|
7
|
+
============
|
|
8
|
+
|
|
9
|
+
## Platforms
|
|
10
|
+
|
|
11
|
+
* Debian, Ubuntu
|
|
12
|
+
* Red Hat/CentOS/Scientific (6.0+ required) - "EL6-family"
|
|
13
|
+
* Fedora
|
|
14
|
+
* SUSE
|
|
15
|
+
|
|
16
|
+
Tested on:
|
|
17
|
+
|
|
18
|
+
* Ubuntu 10.04, 11.10, 12.04
|
|
19
|
+
* Red Hat 6.1, Scientific 6.1, CentOS 6.3
|
|
20
|
+
|
|
21
|
+
## Cookboooks
|
|
22
|
+
|
|
23
|
+
Requires Opscode's `openssl` cookbook for secure password generation.
|
|
24
|
+
|
|
25
|
+
Requires a C compiler and development headers in order to build the
|
|
26
|
+
`pg` RubyGem to provide Ruby bindings in the `ruby` recipe.
|
|
27
|
+
|
|
28
|
+
Opscode's `build-essential` cookbook provides this functionality on
|
|
29
|
+
Debian, Ubuntu, and EL6-family.
|
|
30
|
+
|
|
31
|
+
While not required, Opscode's `database` cookbook contains resources
|
|
32
|
+
and providers that can interact with a PostgreSQL database. This
|
|
33
|
+
cookbook is a dependency of database.
|
|
34
|
+
|
|
35
|
+
Attributes
|
|
36
|
+
==========
|
|
37
|
+
|
|
38
|
+
The following attributes are set based on the platform, see the
|
|
39
|
+
`attributes/default.rb` file for default values.
|
|
40
|
+
|
|
41
|
+
* `node['postgresql']['version']` - version of postgresql to manage
|
|
42
|
+
* `node['postgresql']['dir']` - home directory of where postgresql
|
|
43
|
+
data and configuration lives.
|
|
44
|
+
|
|
45
|
+
* `node['postgresql']['client']['packages']` - An array of package names
|
|
46
|
+
that should be installed on "client" systems.
|
|
47
|
+
* `node['postgresql']['server']['packages']` - An array of package names
|
|
48
|
+
that should be installed on "server" systems.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
The following attributes are generated in
|
|
52
|
+
`recipe[postgresql::server]`.
|
|
53
|
+
|
|
54
|
+
* `node['postgresql']['password']['postgres']` - randomly generated
|
|
55
|
+
password by the `openssl` cookbook's library.
|
|
56
|
+
* `node['postgresql']['ssl']` - whether to enable SSL (off for version
|
|
57
|
+
8.3, true for 8.4).
|
|
58
|
+
|
|
59
|
+
Recipes
|
|
60
|
+
=======
|
|
61
|
+
|
|
62
|
+
default
|
|
63
|
+
-------
|
|
64
|
+
|
|
65
|
+
Includes the client recipe.
|
|
66
|
+
|
|
67
|
+
client
|
|
68
|
+
------
|
|
69
|
+
|
|
70
|
+
Installs postgresql client packages and development headers during the
|
|
71
|
+
compile phase. Also installs the `pg` Ruby gem during the compile
|
|
72
|
+
phase so it can be made available for the `database` cookbook's
|
|
73
|
+
resources, providers and libraries.
|
|
74
|
+
|
|
75
|
+
ruby
|
|
76
|
+
----
|
|
77
|
+
|
|
78
|
+
**NOTE** This recipe may not currently work when installing Chef with
|
|
79
|
+
the
|
|
80
|
+
["Omnibus" full stack installer](http://opscode.com/chef/install) on
|
|
81
|
+
some platforms due to an incompatibility with OpenSSL. See
|
|
82
|
+
[COOK-1406](http://tickets.opscode.com/browse/COOK-1406)
|
|
83
|
+
|
|
84
|
+
Install the `pg` gem under Chef's Ruby environment so it can be used
|
|
85
|
+
in other recipes.
|
|
86
|
+
|
|
87
|
+
server
|
|
88
|
+
------
|
|
89
|
+
|
|
90
|
+
Includes the `server_debian` or `server_redhat` recipe to get the
|
|
91
|
+
appropriate server packages installed and service managed. Also
|
|
92
|
+
manages the configuration for the server:
|
|
93
|
+
|
|
94
|
+
* generates a strong default password (via `openssl`) for `postgres`
|
|
95
|
+
* sets the password for postgres
|
|
96
|
+
* manages the `pg_hba.conf` file.
|
|
97
|
+
|
|
98
|
+
server\_debian
|
|
99
|
+
--------------
|
|
100
|
+
|
|
101
|
+
Installs the postgresql server packages, manages the postgresql
|
|
102
|
+
service and the postgresql.conf file.
|
|
103
|
+
|
|
104
|
+
server\_redhat
|
|
105
|
+
--------------
|
|
106
|
+
|
|
107
|
+
Manages the postgres user and group (with UID/GID 26, per RHEL package
|
|
108
|
+
conventions), installs the postgresql server packages, initializes the
|
|
109
|
+
database and manages the postgresql service, and manages the
|
|
110
|
+
postgresql.conf file.
|
|
111
|
+
|
|
112
|
+
Resources/Providers
|
|
113
|
+
===================
|
|
114
|
+
|
|
115
|
+
See the [database](http://community.opscode.com/cookbooks/database)
|
|
116
|
+
for resources and providers that can be used for managing PostgreSQL
|
|
117
|
+
users and databases.
|
|
118
|
+
|
|
119
|
+
Usage
|
|
120
|
+
=====
|
|
121
|
+
|
|
122
|
+
On systems that need to connect to a PostgreSQL database, add to a run
|
|
123
|
+
list `recipe[postgresql]` or `recipe[postgresql::client]`.
|
|
124
|
+
|
|
125
|
+
On systems that should be PostgreSQL servers, use
|
|
126
|
+
`recipe[postgresql::server]` on a run list. This recipe does set a
|
|
127
|
+
password and expect to use it. It performs a node.save when Chef is
|
|
128
|
+
not running in `solo` mode. If you're using `chef-solo`, you'll need
|
|
129
|
+
to set the attribute `node['postgresql']['password']['postgres']` in
|
|
130
|
+
your node's `json_attribs` file or in a role.
|
|
131
|
+
|
|
132
|
+
License and Author
|
|
133
|
+
==================
|
|
134
|
+
|
|
135
|
+
Author:: Joshua Timberman (<joshua@opscode.com>)
|
|
136
|
+
Author:: Lamont Granquist (<lamont@opscode.com>)
|
|
137
|
+
|
|
138
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
139
|
+
you may not use this file except in compliance with the License.
|
|
140
|
+
You may obtain a copy of the License at
|
|
141
|
+
|
|
142
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
143
|
+
|
|
144
|
+
Unless required by applicable law or agreed to in writing, software
|
|
145
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
147
|
+
See the License for the specific language governing permissions and
|
|
148
|
+
limitations under the License.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: postgresql
|
|
3
|
+
# Attributes:: postgresql
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2008-2009, Opscode, Inc.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
case platform
|
|
21
|
+
when "debian"
|
|
22
|
+
|
|
23
|
+
case
|
|
24
|
+
when platform_version.to_f <= 5.0
|
|
25
|
+
default['postgresql']['version'] = "8.3"
|
|
26
|
+
when platform_version.to_f == 6.0
|
|
27
|
+
default['postgresql']['version'] = "8.4"
|
|
28
|
+
else
|
|
29
|
+
default['postgresql']['version'] = "9.1"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
set['postgresql']['dir'] = "/etc/postgresql/#{node['postgresql']['version']}/main"
|
|
33
|
+
default['postgresql']['client']['packages'] = %w{postgresql-client libpq-dev}
|
|
34
|
+
default['postgresql']['server']['packages'] = %w{postgresql}
|
|
35
|
+
|
|
36
|
+
when "ubuntu"
|
|
37
|
+
|
|
38
|
+
case
|
|
39
|
+
when platform_version.to_f <= 9.04
|
|
40
|
+
default['postgresql']['version'] = "8.3"
|
|
41
|
+
when platform_version.to_f <= 11.04
|
|
42
|
+
default['postgresql']['version'] = "8.4"
|
|
43
|
+
else
|
|
44
|
+
default['postgresql']['version'] = "9.1"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
set['postgresql']['dir'] = "/etc/postgresql/#{node['postgresql']['version']}/main"
|
|
48
|
+
default['postgresql']['client']['packages'] = %w{postgresql-client libpq-dev}
|
|
49
|
+
default['postgresql']['server']['packages'] = %w{postgresql}
|
|
50
|
+
|
|
51
|
+
when "fedora"
|
|
52
|
+
|
|
53
|
+
if platform_version.to_f <= 12
|
|
54
|
+
default['postgresql']['version'] = "8.3"
|
|
55
|
+
else
|
|
56
|
+
default['postgresql']['version'] = "8.4"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
set['postgresql']['dir'] = "/var/lib/pgsql/data"
|
|
60
|
+
default['postgresql']['client']['packages'] = %w{postgresql-devel}
|
|
61
|
+
default['postgresql']['server']['packages'] = %w{postgresql-server}
|
|
62
|
+
|
|
63
|
+
when "amazon"
|
|
64
|
+
|
|
65
|
+
default['postgresql']['version'] = "8.4"
|
|
66
|
+
set['postgresql']['dir'] = "/var/lib/pgsql/data"
|
|
67
|
+
default['postgresql']['client']['packages'] = %w{postgresql-devel}
|
|
68
|
+
default['postgresql']['server']['packages'] = %w{postgresql-server}
|
|
69
|
+
|
|
70
|
+
when "redhat","centos","scientific"
|
|
71
|
+
|
|
72
|
+
default['postgresql']['version'] = "8.4"
|
|
73
|
+
set['postgresql']['dir'] = "/var/lib/pgsql/data"
|
|
74
|
+
|
|
75
|
+
if node['platform_version'].to_f >= 6.0
|
|
76
|
+
default['postgresql']['client']['packages'] = %w{postgresql-devel}
|
|
77
|
+
default['postgresql']['server']['packages'] = %w{postgresql-server}
|
|
78
|
+
else
|
|
79
|
+
default['postgresql']['client']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-devel"]
|
|
80
|
+
default['postgresql']['server']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-server"]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
when "suse"
|
|
84
|
+
|
|
85
|
+
case
|
|
86
|
+
when platform_version.to_f <= 11.1
|
|
87
|
+
default['postgresql']['version'] = "8.3"
|
|
88
|
+
else
|
|
89
|
+
default['postgresql']['version'] = "9.0"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
set['postgresql']['dir'] = "/var/lib/pgsql/data"
|
|
93
|
+
default['postgresql']['client']['packages'] = %w{postgresql-client libpq-dev}
|
|
94
|
+
default['postgresql']['server']['packages'] = %w{postgresql-server}
|
|
95
|
+
|
|
96
|
+
else
|
|
97
|
+
default['postgresql']['version'] = "8.4"
|
|
98
|
+
set['postgresql']['dir'] = "/etc/postgresql/#{node['postgresql']['version']}/main"
|
|
99
|
+
default['postgresql']['client']['packages'] = ["postgresql"]
|
|
100
|
+
default['postgresql']['server']['packages'] = ["postgresql"]
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
default['postgresql']['listen_addresses'] = "localhost"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
maintainer "Opscode, Inc."
|
|
2
|
+
maintainer_email "cookbooks@opscode.com"
|
|
3
|
+
license "Apache 2.0"
|
|
4
|
+
description "Installs and configures postgresql for clients or servers"
|
|
5
|
+
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
|
6
|
+
version "1.0.1"
|
|
7
|
+
recipe "postgresql", "Includes postgresql::client"
|
|
8
|
+
recipe "postgresql::client", "Installs postgresql client package(s)"
|
|
9
|
+
recipe "postgresql::server", "Installs postgresql server packages, templates"
|
|
10
|
+
recipe "postgresql::server_redhat", "Installs postgresql server packages, redhat family style"
|
|
11
|
+
recipe "postgresql::server_debian", "Installs postgresql server packages, debian family style"
|
|
12
|
+
|
|
13
|
+
%w{ ubuntu debian fedora suse }.each do |os|
|
|
14
|
+
supports os
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
%w{redhat centos scientific}.each do |el|
|
|
18
|
+
supports el, ">= 6.0"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
depends "openssl"
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: postgresql
|
|
3
|
+
# Recipe:: client
|
|
4
|
+
#
|
|
5
|
+
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
|
6
|
+
# Author:: Lamont Granquist (<lamont@opscode.com>)
|
|
7
|
+
# Copyright 2009-2011 Opscode, Inc.
|
|
8
|
+
#
|
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
# you may not use this file except in compliance with the License.
|
|
11
|
+
# You may obtain a copy of the License at
|
|
12
|
+
#
|
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
#
|
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
# See the License for the specific language governing permissions and
|
|
19
|
+
# limitations under the License.
|
|
20
|
+
#
|
|
21
|
+
|
|
22
|
+
node['postgresql']['client']['packages'].each do |pg_pack|
|
|
23
|
+
package pg_pack do
|
|
24
|
+
action :install
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: postgresql
|
|
3
|
+
# Recipe:: default
|
|
4
|
+
#
|
|
5
|
+
# Copyright 2009, Opscode, Inc.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
include_recipe "postgresql::client"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: postgresql
|
|
3
|
+
# Recipe:: ruby
|
|
4
|
+
#
|
|
5
|
+
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
|
6
|
+
# Copyright 2012 Opscode, Inc.
|
|
7
|
+
#
|
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
# you may not use this file except in compliance with the License.
|
|
10
|
+
# You may obtain a copy of the License at
|
|
11
|
+
#
|
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
#
|
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
begin
|
|
22
|
+
require 'pg'
|
|
23
|
+
rescue LoadError
|
|
24
|
+
execute "apt-get update" do
|
|
25
|
+
ignore_failure true
|
|
26
|
+
action :nothing
|
|
27
|
+
end.run_action(:run) if node['platform_family'] == "debian"
|
|
28
|
+
|
|
29
|
+
node.set['build_essential']['compiletime'] = true
|
|
30
|
+
include_recipe "build-essential"
|
|
31
|
+
include_recipe "postgresql::client"
|
|
32
|
+
|
|
33
|
+
node['postgresql']['client']['packages'].each do |pg_pack|
|
|
34
|
+
|
|
35
|
+
resources("package[#{pg_pack}]").run_action(:install)
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
chef_gem "pg"
|
|
40
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#/postgresql.conf.
|
|
2
|
+
# Cookbook Name:: postgresql
|
|
3
|
+
# Recipe:: server
|
|
4
|
+
#
|
|
5
|
+
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
|
6
|
+
# Author:: Lamont Granquist (<lamont@opscode.com>)
|
|
7
|
+
# Copyright 2009-2011, Opscode, Inc.
|
|
8
|
+
#
|
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
# you may not use this file except in compliance with the License.
|
|
11
|
+
# You may obtain a copy of the License at
|
|
12
|
+
#
|
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
#
|
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
# See the License for the specific language governing permissions and
|
|
19
|
+
# limitations under the License.
|
|
20
|
+
#
|
|
21
|
+
|
|
22
|
+
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
|
|
23
|
+
|
|
24
|
+
include_recipe "postgresql::client"
|
|
25
|
+
|
|
26
|
+
# randomly generate postgres password
|
|
27
|
+
node.set_unless['postgresql']['password']['postgres'] = secure_password
|
|
28
|
+
node.save unless Chef::Config[:solo]
|
|
29
|
+
|
|
30
|
+
if node['postgresql']['version'].to_f <= 8.3
|
|
31
|
+
node.default['postgresql']['ssl'] = "off"
|
|
32
|
+
else
|
|
33
|
+
node.default['postgresql']['ssl'] = "true"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Include the right "family" recipe for installing the server
|
|
37
|
+
# since they do things slightly differently.
|
|
38
|
+
case node['platform']
|
|
39
|
+
when "redhat", "centos", "fedora", "suse", "scientific", "amazon"
|
|
40
|
+
include_recipe "postgresql::server_redhat"
|
|
41
|
+
when "debian", "ubuntu"
|
|
42
|
+
include_recipe "postgresql::server_debian"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
template "#{node['postgresql']['dir']}/pg_hba.conf" do
|
|
46
|
+
source "pg_hba.conf.erb"
|
|
47
|
+
owner "postgres"
|
|
48
|
+
group "postgres"
|
|
49
|
+
mode 00600
|
|
50
|
+
notifies :reload, resources(:service => "postgresql"), :immediately
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Default PostgreSQL install has 'ident' checking on unix user 'postgres'
|
|
54
|
+
# and 'md5' password checking with connections from 'localhost'. This script
|
|
55
|
+
# runs as user 'postgres', so we can execute the 'role' and 'database' resources
|
|
56
|
+
# as 'root' later on, passing the below credentials in the PG client.
|
|
57
|
+
bash "assign-postgres-password" do
|
|
58
|
+
user 'postgres'
|
|
59
|
+
code <<-EOH
|
|
60
|
+
echo "ALTER ROLE postgres ENCRYPTED PASSWORD '#{node['postgresql']['password']['postgres']}';" | psql
|
|
61
|
+
EOH
|
|
62
|
+
not_if "echo '\connect' | PGPASSWORD=#{node['postgresql']['password']['postgres']} psql --username=postgres --no-password -h localhost"
|
|
63
|
+
action :run
|
|
64
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: postgresql
|
|
3
|
+
# Recipe:: server
|
|
4
|
+
#
|
|
5
|
+
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
|
6
|
+
# Author:: Lamont Granquist (<lamont@opscode.com>)#
|
|
7
|
+
# Copyright 2009-2011, Opscode, Inc.
|
|
8
|
+
#
|
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
# you may not use this file except in compliance with the License.
|
|
11
|
+
# You may obtain a copy of the License at
|
|
12
|
+
#
|
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
#
|
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
# See the License for the specific language governing permissions and
|
|
19
|
+
# limitations under the License.
|
|
20
|
+
#
|
|
21
|
+
|
|
22
|
+
include_recipe "postgresql::client"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if node['postgresql']['version'].to_f <= 8.3
|
|
26
|
+
node.default['postgresql']['ssl'] = "off"
|
|
27
|
+
else
|
|
28
|
+
node.default['postgresql']['ssl'] = "true"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
node['postgresql']['server']['packages'].each do |pg_pack|
|
|
32
|
+
package pg_pack do
|
|
33
|
+
action :install
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
service "postgresql" do
|
|
38
|
+
case node['platform']
|
|
39
|
+
when "ubuntu"
|
|
40
|
+
case
|
|
41
|
+
when node['platform_version'].to_f <= 10.04
|
|
42
|
+
service_name "postgresql-#{node['postgresql']['version']}"
|
|
43
|
+
else
|
|
44
|
+
service_name "postgresql"
|
|
45
|
+
end
|
|
46
|
+
when "debian"
|
|
47
|
+
case
|
|
48
|
+
when node['platform_version'].to_f <= 5.0
|
|
49
|
+
service_name "postgresql-#{node['postgresql']['version']}"
|
|
50
|
+
else
|
|
51
|
+
service_name "postgresql"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
supports :restart => true, :status => true, :reload => true
|
|
55
|
+
action [:enable, :start]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
template "#{node['postgresql']['dir']}/postgresql.conf" do
|
|
59
|
+
source "debian.postgresql.conf.erb"
|
|
60
|
+
owner "postgres"
|
|
61
|
+
group "postgres"
|
|
62
|
+
mode 0600
|
|
63
|
+
notifies :restart, resources(:service => "postgresql"), :immediately
|
|
64
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cookbook Name:: postgresql
|
|
3
|
+
# Recipe:: server
|
|
4
|
+
#
|
|
5
|
+
# Author:: Joshua Timberman (<joshua@opscode.com>)
|
|
6
|
+
# Author:: Lamont Granquist (<lamont@opscode.com>)
|
|
7
|
+
# Copyright 2009-2011, Opscode, Inc.
|
|
8
|
+
#
|
|
9
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
# you may not use this file except in compliance with the License.
|
|
11
|
+
# You may obtain a copy of the License at
|
|
12
|
+
#
|
|
13
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
#
|
|
15
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
+
# See the License for the specific language governing permissions and
|
|
19
|
+
# limitations under the License.
|
|
20
|
+
#
|
|
21
|
+
|
|
22
|
+
include_recipe "postgresql::client"
|
|
23
|
+
|
|
24
|
+
# Create a group and user like the package will.
|
|
25
|
+
# Otherwise the templates fail.
|
|
26
|
+
|
|
27
|
+
group "postgres" do
|
|
28
|
+
gid 26
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
user "postgres" do
|
|
32
|
+
shell "/bin/bash"
|
|
33
|
+
comment "PostgreSQL Server"
|
|
34
|
+
home "/var/lib/pgsql"
|
|
35
|
+
gid "postgres"
|
|
36
|
+
system true
|
|
37
|
+
uid 26
|
|
38
|
+
supports :manage_home => false
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
node['postgresql']['server']['packages'].each do |pg_pack|
|
|
42
|
+
package pg_pack do
|
|
43
|
+
action :install
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
case node['platform']
|
|
48
|
+
when "redhat","centos","scientific"
|
|
49
|
+
case
|
|
50
|
+
when node['platform_version'].to_f >= 6.0
|
|
51
|
+
package "postgresql-server"
|
|
52
|
+
else
|
|
53
|
+
package "postgresql#{node['postgresql']['version'].split('.').join}-server"
|
|
54
|
+
end
|
|
55
|
+
when "fedora","suse"
|
|
56
|
+
package "postgresql-server"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Following not valid for 9.x version of postgresql
|
|
60
|
+
if node['postgresql']['version'].to_f < 9.0
|
|
61
|
+
execute "/sbin/service postgresql initdb" do
|
|
62
|
+
not_if { ::FileTest.exist?(File.join(node['postgresql']['dir'], "PG_VERSION")) }
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
service "postgresql" do
|
|
67
|
+
supports :restart => true, :status => true, :reload => true
|
|
68
|
+
action [:enable, :start]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
template "#{node['postgresql']['dir']}/postgresql.conf" do
|
|
72
|
+
source "redhat.postgresql.conf.erb"
|
|
73
|
+
owner "postgres"
|
|
74
|
+
group "postgres"
|
|
75
|
+
mode 0600
|
|
76
|
+
notifies :restart, resources(:service => "postgresql"), :immediately
|
|
77
|
+
end
|