syncwrap 2.2.0 → 2.3.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.
- checksums.yaml +4 -4
- data/History.rdoc +30 -0
- data/Manifest.txt +14 -0
- data/README.rdoc +15 -5
- data/Rakefile +3 -14
- data/lib/syncwrap/base.rb +1 -1
- data/lib/syncwrap/components/amazon_linux.rb +50 -0
- data/lib/syncwrap/components/arch.rb +37 -0
- data/lib/syncwrap/components/bundle.rb +111 -0
- data/lib/syncwrap/components/bundled_iyyov_daemon.rb +130 -0
- data/lib/syncwrap/components/bundler_gem.rb +47 -0
- data/lib/syncwrap/components/centos.rb +28 -0
- data/lib/syncwrap/components/cruby_vm.rb +3 -6
- data/lib/syncwrap/components/debian.rb +89 -0
- data/lib/syncwrap/components/hashdot.rb +6 -4
- data/lib/syncwrap/components/iyyov.rb +2 -2
- data/lib/syncwrap/components/jruby_vm.rb +9 -5
- data/lib/syncwrap/components/network.rb +44 -24
- data/lib/syncwrap/components/open_jdk.rb +23 -7
- data/lib/syncwrap/components/postgresql.rb +77 -31
- data/lib/syncwrap/components/puma.rb +146 -0
- data/lib/syncwrap/components/qpid.rb +1 -1
- data/lib/syncwrap/components/rake_gem.rb +46 -0
- data/lib/syncwrap/components/rhel.rb +7 -3
- data/lib/syncwrap/components/run_user.rb +7 -3
- data/lib/syncwrap/components/source_tree.rb +128 -0
- data/lib/syncwrap/components/tarpit_gem.rb +60 -0
- data/lib/syncwrap/components/ubuntu.rb +14 -55
- data/lib/syncwrap/components/users.rb +1 -2
- data/lib/syncwrap/distro.rb +5 -5
- data/lib/syncwrap/ruby_support.rb +20 -4
- data/lib/syncwrap/version_support.rb +62 -0
- data/lib/syncwrap.rb +11 -0
- data/sync/postgresql/postgresql.conf.erb +4 -4
- data/sync/var/iyyov/default/bundled_daemon.rb.erb +31 -0
- data/test/test_components.rb +77 -18
- data/test/test_version_support.rb +65 -0
- metadata +16 -2
@@ -0,0 +1,89 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2011-2014 David Kellum
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License"); you
|
5
|
+
# may not use this file except in compliance with the License. You may
|
6
|
+
# obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
13
|
+
# implied. See the License for the specific language governing
|
14
|
+
# permissions and limitations under the License.
|
15
|
+
#++
|
16
|
+
|
17
|
+
require 'syncwrap/component'
|
18
|
+
require 'syncwrap/distro'
|
19
|
+
require 'syncwrap/version_support'
|
20
|
+
|
21
|
+
module SyncWrap
|
22
|
+
|
23
|
+
# Customizations for \Debian and possibly other deb packaged
|
24
|
+
# derivatives. Specific distros/versions may further specialize.
|
25
|
+
class Debian < Component
|
26
|
+
include SyncWrap::Distro
|
27
|
+
include SyncWrap::VersionSupport
|
28
|
+
|
29
|
+
# Debian version, i.e. '7.6' No default value.
|
30
|
+
attr_accessor :debian_version
|
31
|
+
|
32
|
+
alias :distro_version :debian_version
|
33
|
+
|
34
|
+
def initialize( opts = {} )
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
# Install the specified package names. The first time this is
|
39
|
+
# applied to any given host, an "apt-get update" is issued as
|
40
|
+
# well. A trailing hash is interpreted as options, see below.
|
41
|
+
#
|
42
|
+
# ==== Options
|
43
|
+
# :minimal:: Eqv to --no-install-recommends
|
44
|
+
#
|
45
|
+
# Other options will be ignored.
|
46
|
+
def dist_install( *args )
|
47
|
+
opts = args.last.is_a?( Hash ) && args.pop || {}
|
48
|
+
args.unshift "--no-install-recommends" if opts[ :minimal ]
|
49
|
+
|
50
|
+
sudo( "apt-get -yqq update" ) if first_apt?
|
51
|
+
sudo( "apt-get -yq install #{args.join ' '}" )
|
52
|
+
end
|
53
|
+
|
54
|
+
# Uninstall the specified package names.
|
55
|
+
def dist_uninstall( *pkgs )
|
56
|
+
sudo "aptitude -yq purge #{pkgs.join ' '}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# Install a System V style init.d service script
|
60
|
+
def dist_install_init_service( name )
|
61
|
+
sudo "/usr/sbin/update-rc.d #{name} defaults"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Enable the System V style init.d service
|
65
|
+
def dist_enable_init_service( name )
|
66
|
+
sudo "/usr/sbin/update-rc.d #{name} enable"
|
67
|
+
end
|
68
|
+
|
69
|
+
# Run via sudo, the service command typically supporting 'start',
|
70
|
+
# 'stop', 'restart', 'status', etc. arguments.
|
71
|
+
def dist_service( *args )
|
72
|
+
sudo( [ '/usr/sbin/service', *args ].join( ' ' ) )
|
73
|
+
end
|
74
|
+
|
75
|
+
protected
|
76
|
+
|
77
|
+
def first_apt?
|
78
|
+
s = state
|
79
|
+
if s[ :debian_apt_updated ]
|
80
|
+
false
|
81
|
+
else
|
82
|
+
s[ :debian_apt_updated ] = true
|
83
|
+
true
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
require 'syncwrap/component'
|
18
18
|
|
19
19
|
# For distro class comparison only (pre-load for safety)
|
20
|
-
require 'syncwrap/components/
|
20
|
+
require 'syncwrap/components/debian'
|
21
21
|
|
22
22
|
module SyncWrap
|
23
23
|
|
@@ -63,12 +63,14 @@ module SyncWrap
|
|
63
63
|
|
64
64
|
def install_system_deps
|
65
65
|
deps = %w[ make gcc ]
|
66
|
-
deps +=
|
66
|
+
deps += case distro
|
67
|
+
when Debian
|
67
68
|
%w[ libapr1 libapr1-dev ]
|
68
|
-
|
69
|
+
when RHEL
|
69
70
|
%w[ apr apr-devel ]
|
71
|
+
else
|
72
|
+
%w[ apr ]
|
70
73
|
end
|
71
|
-
|
72
74
|
dist_install( *deps )
|
73
75
|
end
|
74
76
|
|
@@ -17,7 +17,7 @@
|
|
17
17
|
require 'syncwrap/component'
|
18
18
|
|
19
19
|
# For distro class comparison only (pre-load for safety)
|
20
|
-
require 'syncwrap/components/
|
20
|
+
require 'syncwrap/components/debian'
|
21
21
|
|
22
22
|
module SyncWrap
|
23
23
|
|
@@ -138,7 +138,7 @@ module SyncWrap
|
|
138
138
|
# Install iyyov daemon init.d script and add to init daemons
|
139
139
|
def install_iyyov_init
|
140
140
|
rput( 'etc/init.d/iyyov', user: :root,
|
141
|
-
erb_vars: { lsb: distro.kind_of?(
|
141
|
+
erb_vars: { lsb: distro.kind_of?( Debian ) } )
|
142
142
|
|
143
143
|
# Add to init.d
|
144
144
|
dist_install_init_service( 'iyyov' )
|
@@ -16,6 +16,7 @@
|
|
16
16
|
|
17
17
|
require 'syncwrap/component'
|
18
18
|
require 'syncwrap/ruby_support'
|
19
|
+
require 'syncwrap/version_support'
|
19
20
|
|
20
21
|
module SyncWrap
|
21
22
|
|
@@ -25,6 +26,7 @@ module SyncWrap
|
|
25
26
|
#
|
26
27
|
# Host component dependencies: <Distro>
|
27
28
|
class JRubyVM < Component
|
29
|
+
include VersionSupport
|
28
30
|
include RubySupport
|
29
31
|
|
30
32
|
# JRuby version to install (default: 1.7.13)
|
@@ -33,7 +35,8 @@ module SyncWrap
|
|
33
35
|
def initialize( opts = {} )
|
34
36
|
@jruby_version = '1.7.13'
|
35
37
|
|
36
|
-
super( {
|
38
|
+
super( { ruby_command: 'jruby',
|
39
|
+
gem_command: 'jgem' }.merge( opts ) )
|
37
40
|
end
|
38
41
|
|
39
42
|
def jruby_dist_path
|
@@ -83,7 +86,7 @@ module SyncWrap
|
|
83
86
|
#
|
84
87
|
# The jruby jgem command tends to be slow on virtual hardware.
|
85
88
|
# This implementation adds a faster short-circuit when an exact,
|
86
|
-
# single :version is given that avoids calling
|
89
|
+
# single :version is given that avoids calling jgem if the rubygems
|
87
90
|
# same version gemspec file is found.
|
88
91
|
def gem_install( gem, opts = {} )
|
89
92
|
version = Array( opts[ :version ] )
|
@@ -91,7 +94,7 @@ module SyncWrap
|
|
91
94
|
|
92
95
|
unless ( opts[:check] || opts[:user_install] ||
|
93
96
|
opts[:minimize] == false || opts[:spec_check] == false ||
|
94
|
-
|
97
|
+
ver.nil? )
|
95
98
|
|
96
99
|
specs = [ "#{jruby_gem_home}/specifications/#{gem}-#{ver}-java.gemspec",
|
97
100
|
"#{jruby_gem_home}/specifications/#{gem}-#{ver}.gemspec" ]
|
@@ -108,9 +111,10 @@ module SyncWrap
|
|
108
111
|
|
109
112
|
alias :jruby_gem_install :gem_install
|
110
113
|
|
114
|
+
protected
|
115
|
+
|
111
116
|
def min_deps_supported?
|
112
|
-
|
113
|
-
( varray <=> [1, 7, 5] ) >= 0
|
117
|
+
version_gte?( jruby_version, [1,7,5] )
|
114
118
|
end
|
115
119
|
|
116
120
|
def jruby_gem_version_flags( reqs )
|
@@ -15,9 +15,13 @@
|
|
15
15
|
#++
|
16
16
|
|
17
17
|
require 'syncwrap/component'
|
18
|
+
require 'syncwrap/version_support'
|
18
19
|
|
20
|
+
# For distro class comparison only (pre-load for safety)
|
21
|
+
require 'syncwrap/components/debian'
|
19
22
|
require 'syncwrap/components/ubuntu'
|
20
23
|
require 'syncwrap/components/rhel'
|
24
|
+
require 'syncwrap/components/amazon_linux'
|
21
25
|
|
22
26
|
module SyncWrap
|
23
27
|
|
@@ -26,6 +30,7 @@ module SyncWrap
|
|
26
30
|
#
|
27
31
|
# Host component dependencies: <Distro>
|
28
32
|
class Network < Component
|
33
|
+
include VersionSupport
|
29
34
|
|
30
35
|
# A dns search list (a single domain or space delimited list of
|
31
36
|
# domains) for addition to the resolv.conf search option,
|
@@ -47,29 +52,40 @@ module SyncWrap
|
|
47
52
|
|
48
53
|
def update_hostname
|
49
54
|
name = host.name
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
sudo <<-SH
|
56
|
-
if ! grep -q '^HOSTNAME=#{name}$' /etc/sysconfig/network; then
|
57
|
-
cp -f /etc/sysconfig/network /etc/sysconfig/network~
|
58
|
-
sed -i '/^HOSTNAME=.*/d' /etc/sysconfig/network
|
59
|
-
echo 'HOSTNAME=#{name}' >> /etc/sysconfig/network
|
60
|
-
hostname #{name}
|
61
|
-
fi
|
62
|
-
SH
|
63
|
-
when Ubuntu
|
64
|
-
sudo <<-SH
|
65
|
-
if [ ! -e /etc/hostname -o "$(< /etc/hostname)" != "#{name}" ]; then
|
66
|
-
echo #{name} > /etc/hostname
|
67
|
-
hostname #{name}
|
68
|
-
fi
|
69
|
-
SH
|
55
|
+
if ( distro.is_a?( AmazonLinux ) ||
|
56
|
+
( distro.is_a?( RHEL ) && version_lt?( rhel_version, [7] ) ) )
|
57
|
+
set_sysconfig_network( name )
|
58
|
+
else
|
59
|
+
set_etc_hostname( name )
|
70
60
|
end
|
71
61
|
end
|
72
62
|
|
63
|
+
# Test if change to etc/hostname is needed. If so also immediately
|
64
|
+
# set (in kernel) hostname.
|
65
|
+
def set_etc_hostname( name )
|
66
|
+
sudo <<-SH
|
67
|
+
if [ ! -e /etc/hostname -o "$(< /etc/hostname)" != "#{name}" ]; then
|
68
|
+
echo #{name} > /etc/hostname
|
69
|
+
hostname #{name}
|
70
|
+
fi
|
71
|
+
SH
|
72
|
+
end
|
73
|
+
|
74
|
+
# Test if change to etc/sysconfig/network is needed. If so also
|
75
|
+
# immediately set (in kernel) hostname.
|
76
|
+
def set_sysconfig_network( name )
|
77
|
+
# If not already set correctly, backup, delete old line, append
|
78
|
+
# new line.
|
79
|
+
sudo <<-SH
|
80
|
+
if ! grep -q '^HOSTNAME=#{name}$' /etc/sysconfig/network; then
|
81
|
+
cp -f /etc/sysconfig/network /etc/sysconfig/network~
|
82
|
+
sed -i '/^HOSTNAME=.*/d' /etc/sysconfig/network
|
83
|
+
echo 'HOSTNAME=#{name}' >> /etc/sysconfig/network
|
84
|
+
hostname #{name}
|
85
|
+
fi
|
86
|
+
SH
|
87
|
+
end
|
88
|
+
|
73
89
|
def update_resolver
|
74
90
|
if dns_search
|
75
91
|
case distro
|
@@ -85,10 +101,14 @@ module SyncWrap
|
|
85
101
|
fi
|
86
102
|
SH
|
87
103
|
|
88
|
-
when
|
89
|
-
|
90
|
-
|
91
|
-
|
104
|
+
when Debian
|
105
|
+
if distro.is_a?( Ubuntu )
|
106
|
+
# As of 12.04 - Precise; /etc/resolv.conf is a symlink that
|
107
|
+
# should not be lost.
|
108
|
+
update_resolv_conf( '/run/resolvconf/resolv.conf' )
|
109
|
+
else
|
110
|
+
update_resolv_conf
|
111
|
+
end
|
92
112
|
|
93
113
|
f='/etc/network/interfaces'
|
94
114
|
sudo <<-SH
|
@@ -18,17 +18,27 @@ require 'syncwrap/component'
|
|
18
18
|
|
19
19
|
# For distro class comparison only (pre-load for safety)
|
20
20
|
require 'syncwrap/components/rhel'
|
21
|
-
require 'syncwrap/components/
|
21
|
+
require 'syncwrap/components/debian'
|
22
|
+
require 'syncwrap/components/arch'
|
22
23
|
|
23
24
|
module SyncWrap
|
24
25
|
|
25
26
|
# Provision an OpenJDK via Linux distro managed packages.
|
26
27
|
#
|
27
|
-
#
|
28
|
-
# and
|
29
|
-
#
|
28
|
+
# For simplicity, this component only supports the full JDK (runtime
|
29
|
+
# and compiler) and not the JRE (runtime only). Note however that
|
30
|
+
# on Debian distros, installing 'openjdk-7-jdk' ends up pulling in
|
31
|
+
# X11 and leads to signficant system bloat. See:
|
32
|
+
#
|
33
|
+
# https://bugs.launchpad.net/ubuntu/+source/openjdk-6/+bug/257857
|
34
|
+
#
|
35
|
+
# On Debian, only the JRE is available "headless".
|
30
36
|
#
|
31
37
|
# Host component dependencies: <Distro>
|
38
|
+
#
|
39
|
+
# Oracle, Java, and OpenJDK are registered trademarks of Oracle
|
40
|
+
# and/or its affiliates.
|
41
|
+
# See http://openjdk.java.net/legal/openjdk-trademark-notice.html
|
32
42
|
class OpenJDK < Component
|
33
43
|
|
34
44
|
# The JDK major and/or minor version number, i.e "1.7" or "7" is 7.
|
@@ -41,25 +51,31 @@ module SyncWrap
|
|
41
51
|
super
|
42
52
|
end
|
43
53
|
|
54
|
+
# Distro and version dependent JDK installation directory.
|
44
55
|
def jdk_dir
|
45
56
|
case distro
|
46
57
|
when RHEL
|
47
58
|
"/usr/lib/jvm/java-1.#{jdk_major_minor}.0"
|
48
|
-
when
|
59
|
+
when Debian
|
49
60
|
"/usr/lib/jvm/java-#{jdk_major_minor}-openjdk-amd64"
|
61
|
+
when Arch
|
62
|
+
"/usr/lib/jvm/java-#{jdk_major_minor}-openjdk"
|
50
63
|
else
|
51
64
|
raise ContextError, "Unknown distro jdk_dir"
|
52
65
|
end
|
53
66
|
end
|
54
67
|
|
55
|
-
# Install including development headers for
|
68
|
+
# Install distro packages, including development headers for JNI
|
69
|
+
# dependet like Hashdot.
|
56
70
|
def install
|
57
71
|
case distro
|
58
72
|
when RHEL
|
59
73
|
dist_install( "java-1.#{jdk_major_minor}.0-openjdk",
|
60
74
|
"java-1.#{jdk_major_minor}.0-openjdk-devel" )
|
61
|
-
when
|
75
|
+
when Debian
|
62
76
|
dist_install( "openjdk-#{jdk_major_minor}-jdk" )
|
77
|
+
when Arch
|
78
|
+
dist_install( "jdk#{jdk_major_minor}-openjdk" )
|
63
79
|
else
|
64
80
|
raise ContextError, "Unknown distro type"
|
65
81
|
end
|
@@ -15,9 +15,12 @@
|
|
15
15
|
#++
|
16
16
|
|
17
17
|
require 'syncwrap/component'
|
18
|
+
require 'syncwrap/version_support'
|
18
19
|
|
19
20
|
# For distro class comparison only (pre-load for safety)
|
20
21
|
require 'syncwrap/components/rhel'
|
22
|
+
require 'syncwrap/components/amazon_linux'
|
23
|
+
require 'syncwrap/components/debian'
|
21
24
|
require 'syncwrap/components/ubuntu'
|
22
25
|
|
23
26
|
module SyncWrap
|
@@ -25,17 +28,49 @@ module SyncWrap
|
|
25
28
|
# Provisions for install and configuration of a \PostgreSQL server
|
26
29
|
#
|
27
30
|
# Host component dependencies: <Distro>
|
31
|
+
#
|
32
|
+
# Currently provided (sync/postgresql) configuration is \PostgreSQL
|
33
|
+
# 9.x compatible. You will need to provide your own complete
|
34
|
+
# configuration for any other versions.
|
35
|
+
#
|
36
|
+
# Most distros provide reasonably updated \PostgreSQL 9.x in more
|
37
|
+
# recent releases:
|
38
|
+
#
|
39
|
+
# * RHEL, CentOS 6: 8.4
|
40
|
+
# * RHEL, CentOS 7: 9.2
|
41
|
+
# * AmazonLinux 2013.03: 8.4 and 9.2
|
42
|
+
# * Debian 7: 9.1
|
43
|
+
# * Ubuntu 14: 9.3
|
44
|
+
#
|
45
|
+
# The latest stable and beta packages can also be obtained via the
|
46
|
+
# \PostgreSQL {Yum Repo}[http://yum.postgresql.org] or
|
47
|
+
# {Apt Repo}[http://wiki.postgresql.org/wiki/Apt]. Create your own
|
48
|
+
# repo component to install these repo's, then configure the
|
49
|
+
# \PostgreSQL component accordingly for #pg_version,
|
50
|
+
# #pg_default_data_dir, #package_names.
|
51
|
+
#
|
28
52
|
class PostgreSQL < Component
|
53
|
+
include VersionSupport
|
29
54
|
|
30
55
|
# \PostgreSQL _MAJOR.MINOR_ version to install. Since there are
|
31
56
|
# multiple versions in use even for _default_ system packages across
|
32
57
|
# distros, this should be set the same as the version that will
|
33
|
-
# be installed via #package_names.
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def
|
38
|
-
|
58
|
+
# be installed via #package_names.
|
59
|
+
# (Default: guess based on distro/version or '9.1')
|
60
|
+
attr_writer :pg_version
|
61
|
+
|
62
|
+
def pg_version
|
63
|
+
( @pg_version ||
|
64
|
+
( case distro
|
65
|
+
when AmazonLinux
|
66
|
+
'9.2' if version_gte?( amazon_version, [2013,3] )
|
67
|
+
when RHEL
|
68
|
+
'9.2' if version_gte?( rhel_version, [7] )
|
69
|
+
when Ubuntu
|
70
|
+
'9.3' if version_gte?( ubuntu_version, [14,4] )
|
71
|
+
end
|
72
|
+
) ||
|
73
|
+
'9.1' )
|
39
74
|
end
|
40
75
|
|
41
76
|
# Location of postgresql data (and possibly also config) directory.
|
@@ -48,38 +83,50 @@ module SyncWrap
|
|
48
83
|
|
49
84
|
protected
|
50
85
|
|
86
|
+
# Deprecated
|
87
|
+
alias :version :pg_version
|
88
|
+
|
89
|
+
# Deprecated
|
90
|
+
alias :version= :pg_version=
|
91
|
+
|
92
|
+
protected :version, :version=
|
93
|
+
|
51
94
|
# The _default_ data dir as used by the distro #package_names.
|
52
|
-
# (Default: as per RHEL
|
95
|
+
# (Default: as per RHEL/Debian package conventions)
|
53
96
|
attr_writer :pg_default_data_dir
|
54
97
|
|
55
98
|
def pg_default_data_dir
|
56
|
-
@pg_default_data_dir ||
|
57
|
-
case distro
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
99
|
+
( @pg_default_data_dir ||
|
100
|
+
( case distro
|
101
|
+
when AmazonLinux
|
102
|
+
'/var/lib/pgsql9/data'
|
103
|
+
when RHEL
|
104
|
+
if version_lt?( rhel_version, [7] )
|
105
|
+
'/var/lib/pgsql9/data'
|
106
|
+
end
|
107
|
+
when Debian
|
108
|
+
"/var/lib/postgresql/#{pg_version}/main"
|
109
|
+
end ) ||
|
110
|
+
'/var/lib/pgsql/data' )
|
65
111
|
end
|
66
112
|
|
67
113
|
# Configuration in the '/etc' directory root?
|
68
|
-
# (Default: true on
|
114
|
+
# (Default: true on Debian only, per distro package conventions)
|
69
115
|
attr_writer :pg_specify_etc_config
|
70
116
|
|
71
117
|
def pg_specify_etc_config
|
72
|
-
@pg_specify_etc_config || distro.is_a?(
|
118
|
+
@pg_specify_etc_config || distro.is_a?( Debian )
|
73
119
|
end
|
74
120
|
|
75
121
|
# The package names, including \PostgreSQL server of the
|
76
122
|
# desired version to install.
|
77
|
-
# (Default:
|
123
|
+
# (Default: guess based on distro)
|
78
124
|
attr_writer :package_names
|
79
125
|
|
80
126
|
def package_names
|
81
127
|
( @package_names ||
|
82
|
-
( distro.is_a?(
|
128
|
+
( distro.is_a?( Debian ) && [ "postgresql-#{pg_version}" ] ) ||
|
129
|
+
( distro.is_a?( AmazonLinux ) && [ "postgresql9-server" ] ) ||
|
83
130
|
[ "postgresql-server" ] )
|
84
131
|
end
|
85
132
|
|
@@ -141,21 +188,20 @@ module SyncWrap
|
|
141
188
|
|
142
189
|
# Kernel SHMMAX (Shared Memory Maximum) setting to apply.
|
143
190
|
# Note that PostgreSQL 9.3 uses mmap and should not need this.
|
144
|
-
# Currently this
|
145
|
-
#
|
191
|
+
# Currently this only set on Debian distros.
|
192
|
+
# (Default: 300MB if #pg_version < 9.3)
|
146
193
|
attr_writer :shared_memory_max
|
147
194
|
|
148
195
|
def shared_memory_max
|
149
|
-
@shared_memory_max ||
|
150
|
-
( ( (version_a <=> [9,3]) < 0 ) && 300_000_000 )
|
196
|
+
@shared_memory_max || ( version_lt?(pg_version, [9,3]) && 300_000_000 )
|
151
197
|
end
|
152
198
|
|
153
199
|
def pg_config_dir
|
154
200
|
case distro
|
155
201
|
when RHEL
|
156
202
|
pg_data_dir
|
157
|
-
when
|
158
|
-
"/etc/postgresql/#{
|
203
|
+
when Debian
|
204
|
+
"/etc/postgresql/#{pg_version}/main"
|
159
205
|
else
|
160
206
|
raise ContextError, "Distro #{distro.class.name} not supported"
|
161
207
|
end
|
@@ -166,7 +212,7 @@ module SyncWrap
|
|
166
212
|
def initialize( opts = {} )
|
167
213
|
@pg_data_dir = nil
|
168
214
|
@pg_default_data_dir = nil
|
169
|
-
@
|
215
|
+
@pg_version = nil
|
170
216
|
@package_names = nil
|
171
217
|
@service_name = 'postgresql'
|
172
218
|
@synchronous_commit = :on
|
@@ -201,12 +247,12 @@ module SyncWrap
|
|
201
247
|
changes
|
202
248
|
end
|
203
249
|
|
204
|
-
# Install the #package_names. In the
|
250
|
+
# Install the #package_names. In the Debian case, also install any
|
205
251
|
# #shared_memory_max adjustment and stops the server for subsequent
|
206
252
|
# reconfigure or data relocation.
|
207
253
|
def package_install
|
208
254
|
dist_install( *package_names )
|
209
|
-
if distro.is_a?(
|
255
|
+
if distro.is_a?( Debian )
|
210
256
|
pg_stop
|
211
257
|
if shared_memory_max
|
212
258
|
rput( 'etc/sysctl.d/61-postgresql-shm.conf', user: :root )
|
@@ -235,7 +281,7 @@ module SyncWrap
|
|
235
281
|
dist_service( service_name, 'initdb' )
|
236
282
|
end
|
237
283
|
|
238
|
-
when
|
284
|
+
when Debian
|
239
285
|
unless pg_data_dir == pg_default_data_dir
|
240
286
|
sudo <<-SH
|
241
287
|
mkdir -p #{pg_data_dir}
|
@@ -254,7 +300,7 @@ module SyncWrap
|
|
254
300
|
# Update the \PostgreSQL configuration files
|
255
301
|
def pg_configure
|
256
302
|
files = %w[ pg_hba.conf pg_ident.conf postgresql.conf ]
|
257
|
-
files += %w[ environment pg_ctl.conf ] if distro.is_a?(
|
303
|
+
files += %w[ environment pg_ctl.conf ] if distro.is_a?( Debian )
|
258
304
|
files = files.map { |f| File.join( 'postgresql', f ) }
|
259
305
|
rput( *files, pg_config_dir, user: 'postgres' )
|
260
306
|
end
|