server_maint 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,13 +27,21 @@ The following platforms are supported by this cookbook, meaning that the recipes
27
27
  ## Recipes
28
28
 
29
29
  * `postgresql` - Set up the apt repository and install dependent packages
30
+ * `postgresql::apt_repository` - Internal recipe to setup the apt repository
30
31
  * `postgresql::client` - Front-end programs for PostgreSQL 9.x
31
- * `postgresql::server` - Object-relational SQL database, version 9.x server
32
+ * `postgresql::configuration` - Internal recipe to manage configuration files
32
33
  * `postgresql::contrib` - Additional facilities for PostgreSQL
34
+ * `postgresql::data_directory` - Internal recipe to setup the data directory
33
35
  * `postgresql::dbg` - Debug symbols for the server daemon
36
+ * `postgresql::debian_backports` - Internal recipe to manage debian backports
34
37
  * `postgresql::doc` - Documentation for the PostgreSQL database management system
35
38
  * `postgresql::libpq` - PostgreSQL C client library and header files for libpq5 (PostgreSQL library)
39
+ * `postgresql::pg_database` - Internal recipe to manage specified databases
40
+ * `postgresql::pg_user` - Internal recipe to manage specified users
36
41
  * `postgresql::postgis` - Geographic objects support for PostgreSQL 9.x
42
+ * `postgresql::server` - Object-relational SQL database, version 9.x server
43
+ * `postgresql::server_dev` - Development files for PostgreSQL server-side programming
44
+ * `postgresql::service` - Internal recipe to declare the system service
37
45
 
38
46
 
39
47
  ## Usage
@@ -576,6 +584,8 @@ Many thanks go to the following who have contributed to making this cookbook eve
576
584
  * fix for missing ssl directives in `postgresql.conf`
577
585
  * **[@cdoughty77](https://github.com/cdoughty77)**
578
586
  * allow finer tuning inside pg_hba.conf file
587
+ * **[@NOX73](https://github.com/NOX73)**
588
+ * fix `postgresql.conf` ssl parameter failure on 9.1
579
589
 
580
590
 
581
591
 
@@ -4,16 +4,24 @@ maintainer_email "github@phlippers.net"
4
4
  license "MIT"
5
5
  description "Installs PostgreSQL, The world's most advanced open source database."
6
6
  long_description IO.read(File.join(File.dirname(__FILE__), "README.md"))
7
- version "0.9.0"
7
+ version "0.10.1"
8
8
 
9
- recipe "postgresql", "Set up the apt repository and install dependent packages"
10
- recipe "postgresql::client", "Front-end programs for PostgreSQL 9.x"
11
- recipe "postgresql::server", "Object-relational SQL database, version 9.x server"
12
- recipe "postgresql::contrib", "Additional facilities for PostgreSQL"
13
- recipe "postgresql::dbg", "Debug symbols for the server daemon"
14
- recipe "postgresql::doc", "Documentation for the PostgreSQL database management system"
15
- recipe "postgresql::libpq", "PostgreSQL C client library and header files for libpq5 (PostgreSQL library)"
16
- recipe "postgresql::postgis", "Geographic objects support for PostgreSQL 9.x"
9
+ recipe "postgresql", "Set up the apt repository and install dependent packages"
10
+ recipe "postgresql::apt_repository", "Internal recipe to setup the apt repository"
11
+ recipe "postgresql::client", "Front-end programs for PostgreSQL 9.x"
12
+ recipe "postgresql::configuration", "Internal recipe to manage configuration files"
13
+ recipe "postgresql::contrib", "Additional facilities for PostgreSQL"
14
+ recipe "postgresql::data_directory", "Internal recipe to setup the data directory"
15
+ recipe "postgresql::dbg", "Debug symbols for the server daemon"
16
+ recipe "postgresql::debian_backports", "Internal recipe to manage debian backports"
17
+ recipe "postgresql::doc", "Documentation for the PostgreSQL database management system"
18
+ recipe "postgresql::libpq", "PostgreSQL C client library and header files for libpq5 (PostgreSQL library)"
19
+ recipe "postgresql::pg_database", "Internal recipe to manage specified databases"
20
+ recipe "postgresql::pg_user", "Internal recipe to manage specified users"
21
+ recipe "postgresql::postgis", "Geographic objects support for PostgreSQL 9.x"
22
+ recipe "postgresql::server", "Object-relational SQL database, version 9.x server"
23
+ recipe "postgresql::server_dev", "Development files for PostgreSQL server-side programming"
24
+ recipe "postgresql::service", "Internal recipe to declare the system service"
17
25
 
18
26
  %w[ubuntu debian].each do |os|
19
27
  supports os
@@ -0,0 +1,17 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: apt_repository
4
+ #
5
+
6
+
7
+ # use `apt.postgresql.org` for primary package installation support
8
+ apt_repository "apt.postgresql.org" do
9
+ uri "http://apt.postgresql.org/pub/repos/apt"
10
+ distribution "#{node["lsb"]["codename"]}-pgdg"
11
+ components ["main"]
12
+ key "http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc"
13
+ action :add
14
+ end
15
+
16
+ # automatically get repository key updates
17
+ package "pgdg-keyring"
@@ -0,0 +1,63 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: configuration
4
+ #
5
+
6
+
7
+ pg_version = node["postgresql"]["version"]
8
+
9
+ # environment
10
+ template "/etc/postgresql/#{pg_version}/main/environment" do
11
+ source "environment.erb"
12
+ owner "postgres"
13
+ group "postgres"
14
+ mode "0644"
15
+ notifies :restart, "service[postgresql]"
16
+ end
17
+
18
+ # pg_ctl
19
+ template "/etc/postgresql/#{pg_version}/main/pg_ctl.conf" do
20
+ source "pg_ctl.conf.erb"
21
+ owner "postgres"
22
+ group "postgres"
23
+ mode "0644"
24
+ notifies :restart, "service[postgresql]"
25
+ end
26
+
27
+ # pg_hba
28
+ template node["postgresql"]["hba_file"] do
29
+ source "pg_hba.conf.erb"
30
+ owner "postgres"
31
+ group "postgres"
32
+ mode "0640"
33
+ notifies :restart, "service[postgresql]"
34
+ end
35
+
36
+ # pg_ident
37
+ template node["postgresql"]["ident_file"] do
38
+ source "pg_ident.conf.erb"
39
+ owner "postgres"
40
+ group "postgres"
41
+ mode "0640"
42
+ notifies :restart, "service[postgresql]"
43
+ end
44
+
45
+ # postgresql
46
+ pg_template_source = node["postgresql"]["conf"].any? ? "custom" : "standard"
47
+ template "/etc/postgresql/#{pg_version}/main/postgresql.conf" do
48
+ source "postgresql.conf.#{pg_template_source}.erb"
49
+ owner "postgres"
50
+ group "postgres"
51
+ mode "0644"
52
+ variables(:configuration => node["postgresql"]["conf"])
53
+ notifies :restart, "service[postgresql]"
54
+ end
55
+
56
+ # start
57
+ template "/etc/postgresql/#{pg_version}/main/start.conf" do
58
+ source "start.conf.erb"
59
+ owner "postgres"
60
+ group "postgres"
61
+ mode "0644"
62
+ notifies :restart, "service[postgresql]", :immediately
63
+ end
@@ -0,0 +1,25 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: data_directory
4
+ #
5
+
6
+
7
+ # ensure data directory exists
8
+ directory node["postgresql"]["data_directory"] do
9
+ owner "postgres"
10
+ group "postgres"
11
+ mode "0700"
12
+ not_if "test -f #{node["postgresql"]["data_directory"]}/PG_VERSION"
13
+ end
14
+
15
+ # initialize the data directory if necessary
16
+ bash "postgresql initdb" do
17
+ user "postgres"
18
+ code <<-EOC
19
+ /usr/lib/postgresql/#{node["postgresql"]["version"]}/bin/initdb \
20
+ #{node["postgresql"]["initdb_options"]} \
21
+ -U postgres \
22
+ -D #{node["postgresql"]["data_directory"]}
23
+ EOC
24
+ creates "#{node["postgresql"]["data_directory"]}/PG_VERSION"
25
+ end
@@ -0,0 +1,20 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: debian_backports
4
+ #
5
+
6
+
7
+ # backports for initial support
8
+ apt_repository "debian-backports" do
9
+ uri "http://backports.debian.org/debian-backports"
10
+ distribution "#{node["lsb"]["codename"]}-backports"
11
+ components ["main"]
12
+ action :add
13
+ end
14
+
15
+ # backports support for debian
16
+ %w[libpq5 postgresql-common].each do |pkg|
17
+ package pkg do
18
+ options "-t #{node["lsb"]["codename"]}-backports"
19
+ end
20
+ end
@@ -3,48 +3,17 @@
3
3
  # Recipe:: default
4
4
  #
5
5
 
6
- case node["platform"]
7
- when "ubuntu"
8
-
9
- apt_repository "pitti-postgresql" do
10
- uri "http://ppa.launchpad.net/pitti/postgresql/ubuntu"
11
- distribution node["lsb"]["codename"]
12
- components ["main"]
13
- keyserver "keyserver.ubuntu.com"
14
- key "8683D8A2"
15
- action :add
16
- end
17
6
 
18
- # install common files
19
- package "postgresql-common"
7
+ # pin default package preferences
8
+ cookbook_file "/etc/apt/preferences.d/pgdg.pref" do
9
+ source "pgdg.pref"
10
+ end
20
11
 
12
+ case node["platform"]
13
+ when "ubuntu"
14
+ include_recipe "postgresql::apt_repository"
15
+ package "postgresql-common" # install common files
21
16
  when "debian"
22
-
23
- # backports for initial support
24
- apt_repository "debian-backports" do
25
- uri "http://backports.debian.org/debian-backports"
26
- distribution "#{node["lsb"]["codename"]}-backports"
27
- components ["main"]
28
- action :add
29
- end
30
-
31
- cookbook_file "/etc/apt/preferences.d/pgdg.pref" do
32
- source "pgdg.pref"
33
- end
34
-
35
- # backports support for debian
36
- %w[libpq5 postgresql-common].each do |pkg|
37
- package pkg do
38
- options "-t #{node["lsb"]["codename"]}-backports"
39
- end
40
- end
41
-
42
- # use `apt.postgresql.org` for primary package installation support
43
- apt_repository "apt.postgresql.org" do
44
- uri "http://apt.postgresql.org/pub/repos/apt"
45
- distribution "#{node["lsb"]["codename"]}-pgdg"
46
- components ["main"]
47
- key "http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc"
48
- action :add
49
- end
17
+ include_recipe "postgresql::debian_backports"
18
+ include_recipe "postgresql::apt_repository"
50
19
  end
@@ -0,0 +1,21 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: pg_database
4
+ #
5
+
6
+
7
+ # setup databases
8
+ node["postgresql"]["databases"].each do |database|
9
+ pg_database database["name"] do
10
+ owner database["owner"]
11
+ encoding database["encoding"]
12
+ template database["template"]
13
+ locale database["locale"]
14
+ end
15
+
16
+ pg_database_extensions database["name"] do
17
+ extensions database["extensions"]
18
+ languages database["languages"]
19
+ postgis database["postgis"]
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: pg_user
4
+ #
5
+
6
+
7
+ # setup users
8
+ node["postgresql"]["users"].each do |user|
9
+ pg_user user["username"] do
10
+ privileges :superuser => user["superuser"], :createdb => user["createdb"], :login => user["login"]
11
+ password user["password"]
12
+ end
13
+ end
@@ -5,114 +5,20 @@
5
5
 
6
6
  include_recipe "postgresql"
7
7
 
8
- pg_version = node["postgresql"]["version"]
9
-
10
8
  # install the package
11
- package "postgresql-#{pg_version}"
12
-
13
-
14
- # ensure data directory exists
15
- directory node["postgresql"]["data_directory"] do
16
- owner "postgres"
17
- group "postgres"
18
- mode "0700"
19
- not_if "test -f #{node["postgresql"]["data_directory"]}/PG_VERSION"
20
- end
21
-
22
- # initialize the data directory if necessary
23
- bash "postgresql initdb" do
24
- user "postgres"
25
- code <<-EOC
26
- /usr/lib/postgresql/#{pg_version}/bin/initdb \
27
- #{node["postgresql"]["initdb_options"]} \
28
- -U postgres \
29
- -D #{node["postgresql"]["data_directory"]}
30
- EOC
31
- creates "#{node["postgresql"]["data_directory"]}/PG_VERSION"
32
- end
33
-
34
- # environment
35
- template "/etc/postgresql/#{pg_version}/main/environment" do
36
- source "environment.erb"
37
- owner "postgres"
38
- group "postgres"
39
- mode "0644"
40
- notifies :restart, "service[postgresql]"
41
- end
9
+ package "postgresql-#{node["postgresql"]["version"]}"
42
10
 
43
- # pg_ctl
44
- template "/etc/postgresql/#{pg_version}/main/pg_ctl.conf" do
45
- source "pg_ctl.conf.erb"
46
- owner "postgres"
47
- group "postgres"
48
- mode "0644"
49
- notifies :restart, "service[postgresql]"
50
- end
11
+ # setup the data directory
12
+ include_recipe "postgresql::data_directory"
51
13
 
52
- # pg_hba
53
- template node["postgresql"]["hba_file"] do
54
- source "pg_hba.conf.erb"
55
- owner "postgres"
56
- group "postgres"
57
- mode "0640"
58
- notifies :restart, "service[postgresql]"
59
- end
60
-
61
- # pg_ident
62
- template node["postgresql"]["ident_file"] do
63
- source "pg_ident.conf.erb"
64
- owner "postgres"
65
- group "postgres"
66
- mode "0640"
67
- notifies :restart, "service[postgresql]"
68
- end
69
-
70
- # postgresql
71
- pg_template_source = node["postgresql"]["conf"].any? ? "custom" : "standard"
72
- template "/etc/postgresql/#{pg_version}/main/postgresql.conf" do
73
- source "postgresql.conf.#{pg_template_source}.erb"
74
- owner "postgres"
75
- group "postgres"
76
- mode "0644"
77
- variables(:configuration => node["postgresql"]["conf"])
78
- notifies :restart, "service[postgresql]"
79
- end
80
-
81
- # start
82
- template "/etc/postgresql/#{pg_version}/main/start.conf" do
83
- source "start.conf.erb"
84
- owner "postgres"
85
- group "postgres"
86
- mode "0644"
87
- notifies :restart, "service[postgresql]", :immediately
88
- end
14
+ # add the configuration
15
+ include_recipe "postgresql::configuration"
89
16
 
90
17
  # setup users
91
- node["postgresql"]["users"].each do |user|
92
- pg_user user["username"] do
93
- privileges :superuser => user["superuser"], :createdb => user["createdb"], :login => user["login"]
94
- password user["password"]
95
- end
96
- end
18
+ include_recipe "postgresql::pg_user"
97
19
 
98
20
  # setup databases
99
- node["postgresql"]["databases"].each do |database|
100
- pg_database database["name"] do
101
- owner database["owner"]
102
- encoding database["encoding"]
103
- template database["template"]
104
- locale database["locale"]
105
- end
106
-
107
- pg_database_extensions database["name"] do
108
- extensions database["extensions"]
109
- languages database["languages"]
110
- postgis database["postgis"]
111
- end
112
- end
21
+ include_recipe "postgresql::pg_database"
113
22
 
114
- # define the service
115
- service "postgresql" do
116
- supports :restart => true
117
- action [:enable, :start]
118
- end
23
+ # declare the system service
24
+ include_recipe "postgresql::service"
@@ -0,0 +1,9 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: server_dev
4
+ #
5
+
6
+ include_recipe "postgresql"
7
+
8
+ # install the package
9
+ package "postgresql-server-dev-#{node["postgresql"]["version"]}"
@@ -0,0 +1,11 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: service
4
+ #
5
+
6
+
7
+ # define the service
8
+ service "postgresql" do
9
+ supports :restart => true
10
+ action [:enable, :start]
11
+ end
@@ -81,8 +81,10 @@ ssl = <%= node["postgresql"]["ssl"] %> # (change requires restart)
81
81
  #ssl_ciphers = '<%= node["postgresql"]["ssl_ciphers"] %>' # allowed SSL ciphers
82
82
  # (change requires restart)
83
83
  #ssl_renegotiation_limit = <%= node["postgresql"]["ssl_renegotiation_limit"] %> # amount of data between renegotiations
84
+ <% if node["postgresql"]["version"].to_f > 9.1 %>
84
85
  ssl_cert_file = '<%= node["postgresql"]["ssl_cert_file"] %>' # (change requires restart)
85
86
  ssl_key_file = '<%= node["postgresql"]["ssl_key_file"] %>' # (change requires restart)
87
+ <% end %>
86
88
  #password_encryption = <%= node["postgresql"]["password_encryption"] %>
87
89
  #db_user_namespace = <%= node["postgresql"]["db_user_namespace"] %>
88
90
 
@@ -1,3 +1,3 @@
1
1
  module ServerMaint
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: server_maint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
12
+ date: 2013-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -308,14 +308,22 @@ files:
308
308
  - lib/cookbooks/postgresql/definitions/pg_user.rb
309
309
  - lib/cookbooks/postgresql/files/default/pgdg.pref
310
310
  - lib/cookbooks/postgresql/metadata.rb
311
+ - lib/cookbooks/postgresql/recipes/apt_repository.rb
311
312
  - lib/cookbooks/postgresql/recipes/client.rb
313
+ - lib/cookbooks/postgresql/recipes/configuration.rb
312
314
  - lib/cookbooks/postgresql/recipes/contrib.rb
315
+ - lib/cookbooks/postgresql/recipes/data_directory.rb
313
316
  - lib/cookbooks/postgresql/recipes/dbg.rb
317
+ - lib/cookbooks/postgresql/recipes/debian_backports.rb
314
318
  - lib/cookbooks/postgresql/recipes/default.rb
315
319
  - lib/cookbooks/postgresql/recipes/doc.rb
316
320
  - lib/cookbooks/postgresql/recipes/libpq.rb
321
+ - lib/cookbooks/postgresql/recipes/pg_database.rb
322
+ - lib/cookbooks/postgresql/recipes/pg_user.rb
317
323
  - lib/cookbooks/postgresql/recipes/postgis.rb
318
324
  - lib/cookbooks/postgresql/recipes/server.rb
325
+ - lib/cookbooks/postgresql/recipes/server_dev.rb
326
+ - lib/cookbooks/postgresql/recipes/service.rb
319
327
  - lib/cookbooks/postgresql/templates/default/environment.erb
320
328
  - lib/cookbooks/postgresql/templates/default/pg_ctl.conf.erb
321
329
  - lib/cookbooks/postgresql/templates/default/pg_hba.conf.erb
@@ -398,7 +406,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
398
406
  version: '0'
399
407
  segments:
400
408
  - 0
401
- hash: -2580774400873308883
409
+ hash: 1737788494550114766
402
410
  required_rubygems_version: !ruby/object:Gem::Requirement
403
411
  none: false
404
412
  requirements:
@@ -407,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
415
  version: '0'
408
416
  segments:
409
417
  - 0
410
- hash: -2580774400873308883
418
+ hash: 1737788494550114766
411
419
  requirements: []
412
420
  rubyforge_project:
413
421
  rubygems_version: 1.8.23