dust-deploy 0.10.8 → 0.11.0
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/changelog.md +8 -0
- data/lib/dust/recipes/postgres.rb +38 -29
- data/lib/dust/version.rb +1 -1
- metadata +4 -4
data/changelog.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Changelog
|
2
2
|
=============
|
3
3
|
|
4
|
+
0.11.0
|
5
|
+
------------
|
6
|
+
|
7
|
+
- refactors the postgres recipe, should now be cleaner and easier for standard setups.
|
8
|
+
now supports profiles and defaults to postgresql-defaults.
|
9
|
+
if you want to use the automatic configuration for dedicated servers (use all system ressources for the database), you have to specify "profile: dedicated" in your config file. have a look at the [postgres recipe wiki page](https://github.com/kechagia/dust-deploy/wiki/postgres) for information
|
10
|
+
|
11
|
+
|
4
12
|
0.10.8
|
5
13
|
------------
|
6
14
|
|
@@ -1,23 +1,33 @@
|
|
1
1
|
class Postgres < Recipe
|
2
2
|
desc 'postgres:deploy', 'installs and configures postgresql database'
|
3
3
|
def deploy
|
4
|
-
|
5
|
-
|
4
|
+
# version: 9.1
|
5
|
+
# package: postgresql-9.1
|
6
|
+
# profile: [ dedicated|standard, zabbix, pacemaker ]
|
7
|
+
# service_name: "service name for init scripts"
|
6
8
|
|
7
|
-
@config['
|
9
|
+
return ::Dust.print_failed 'please specify version in your config file, e.g. "version: 9.1"' unless @config['version']
|
10
|
+
return unless install_postgres
|
8
11
|
|
9
12
|
# default cluster on debian-like systems is 'main'
|
10
13
|
@config['cluster'] ||= 'main' if @node.uses_apt?
|
11
14
|
|
15
|
+
|
12
16
|
set_default_directories
|
13
17
|
deploy_config
|
14
18
|
deploy_recovery
|
15
19
|
deploy_certificates if @config['server.crt'] and @config['server.key']
|
16
|
-
create_archive
|
17
20
|
set_permissions
|
18
21
|
|
19
|
-
|
20
|
-
|
22
|
+
# configure pacemaker profile
|
23
|
+
if @config['profile'].to_array.include? 'pacemaker'
|
24
|
+
deploy_pacemaker_script if @node.package_installed? 'pacemaker'
|
25
|
+
end
|
26
|
+
|
27
|
+
# configure zabbix profile
|
28
|
+
if @config['profile'].to_array.include? 'zabbix'
|
29
|
+
configure_for_zabbix if zabbix_installed?
|
30
|
+
end
|
21
31
|
|
22
32
|
# reload/restart postgres if command line option is given
|
23
33
|
@node.restart_service @config['service_name'] if options.restart?
|
@@ -31,36 +41,41 @@ class Postgres < Recipe
|
|
31
41
|
@node.print_service_status @config['service_name']
|
32
42
|
end
|
33
43
|
|
44
|
+
|
34
45
|
private
|
35
46
|
|
36
47
|
def install_postgres
|
37
|
-
if @
|
48
|
+
if @config['package']
|
49
|
+
package = @config['package']
|
50
|
+
elsif @node.uses_apt?
|
38
51
|
package = "postgresql-#{@config['version']}"
|
39
52
|
elsif @node.uses_emerge?
|
40
53
|
package = 'postgresql-server'
|
41
54
|
else
|
42
|
-
return ::Dust.print_failed 'os not supported'
|
55
|
+
return ::Dust.print_failed 'os not supported, please specify "package: <package name>" in your config'
|
43
56
|
end
|
44
57
|
|
45
58
|
@node.install_package package
|
46
|
-
|
47
|
-
# also install the postgresql meta package
|
48
|
-
# @node.install_package 'postgresql' if @node.uses_apt?
|
49
59
|
end
|
50
60
|
|
51
|
-
# set conf-dir
|
61
|
+
# set conf-dir and data-dir as well as service-name
|
52
62
|
# according to config file, or use standard values of distribution
|
53
63
|
def set_default_directories
|
54
|
-
|
64
|
+
@config['postgresql.conf'] ||= {} # create empty config, unless present
|
65
|
+
|
66
|
+
if @config['cluster']
|
67
|
+
@config['conf_directory'] ||= "/etc/postgresql/#{@config['version']}/#{@config['cluster']}"
|
68
|
+
@config['postgresql.conf']['data_directory'] ||= "/var/lib/postgresql/#{@config['version']}/#{@config['cluster']}"
|
69
|
+
else
|
55
70
|
@config['conf_directory'] ||= "/etc/postgresql-#{@config['version']}"
|
56
|
-
@config['archive_directory'] ||= "/var/lib/postgresql/#{@config['version']}/archive"
|
57
|
-
@config['service_name'] ||= "postgresql-#{@config['version']}"
|
58
71
|
@config['postgresql.conf']['data_directory'] ||= "/var/lib/postgresql/#{@config['version']}/data"
|
72
|
+
end
|
59
73
|
|
60
|
-
|
61
|
-
@config['
|
62
|
-
|
63
|
-
|
74
|
+
if @node.uses_emerge?
|
75
|
+
@config['service_name'] ||= "postgresql-#{@config['version']}"
|
76
|
+
else
|
77
|
+
# on non-debian and non-emerge systems, print a warning since I'm not sure if service name is correct.
|
78
|
+
Dust.print_warning 'service_name not specified in config, defaulting to "postgresql"' unless @node.uses_apt?
|
64
79
|
@config['service_name'] ||= 'postgresql'
|
65
80
|
end
|
66
81
|
|
@@ -109,7 +124,8 @@ class Postgres < Recipe
|
|
109
124
|
@config['postgresql.conf'] ||= {}
|
110
125
|
@config['postgresql.conf'] = default_postgres_conf.merge @config['postgresql.conf']
|
111
126
|
|
112
|
-
|
127
|
+
# calculate values if dedicated profile is given
|
128
|
+
profile_dedicated if @config['profile'].to_array.include? 'dedicated'
|
113
129
|
|
114
130
|
postgresql_conf = ''
|
115
131
|
@config['postgresql.conf'].each do |key, value|
|
@@ -144,11 +160,11 @@ class Postgres < Recipe
|
|
144
160
|
|
145
161
|
# try to find good values (but don't overwrite if set in config file) for
|
146
162
|
# shared_buffers, work_mem and maintenance_work_mem, effective_cache_size and wal_buffers
|
147
|
-
def
|
163
|
+
def profile_dedicated
|
148
164
|
@node.collect_facts :quiet => true
|
149
165
|
system_mem = ::Dust.convert_size(@node['memorysize']).to_f
|
150
166
|
|
151
|
-
::Dust.print_msg "calculating recommended settings for #{kb2mb system_mem} ram\n"
|
167
|
+
::Dust.print_msg "calculating recommended settings for a dedicated databse server with #{kb2mb system_mem} ram\n"
|
152
168
|
|
153
169
|
# every connection uses up to work_mem memory, so make sure that even if
|
154
170
|
# max_connections is reached, there's still a bit left.
|
@@ -186,13 +202,6 @@ class Postgres < Recipe
|
|
186
202
|
@node.chmod 'u+Xrw,g-rwx,o-rwx', @config['postgresql.conf']['data_directory']
|
187
203
|
end
|
188
204
|
|
189
|
-
# create archive dir
|
190
|
-
def create_archive
|
191
|
-
@node.mkdir @config['archive_directory']
|
192
|
-
@node.chown @config['dbuser'], @config['archive_directory'] if @config['dbuser']
|
193
|
-
@node.chmod 'u+Xrw,g-rwx,o-rwx', @config['archive_directory']
|
194
|
-
end
|
195
|
-
|
196
205
|
# deploy the pacemaker script
|
197
206
|
def deploy_pacemaker_script
|
198
207
|
@node.deploy_file "#{@template_path}/pacemaker.sh", "#{@config['conf_directory']}/pacemaker.sh", :binding => binding
|
data/lib/dust/version.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 11
|
8
|
+
- 0
|
9
|
+
version: 0.11.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- kris kechagia
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-05-
|
17
|
+
date: 2012-05-04 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|