syncwrap 2.1.3 → 2.2.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 +29 -0
- data/Manifest.txt +7 -10
- data/examples/jruby.rb +1 -1
- data/lib/syncwrap/amazon_ws.rb +12 -2
- data/lib/syncwrap/base.rb +1 -1
- data/lib/syncwrap/component.rb +4 -0
- data/lib/syncwrap/components/cruby_vm.rb +2 -2
- data/lib/syncwrap/components/hashdot.rb +12 -2
- data/lib/syncwrap/components/jruby_vm.rb +2 -2
- data/lib/syncwrap/components/postgresql.rb +164 -44
- data/lib/syncwrap/components/rhel.rb +10 -8
- data/lib/syncwrap/components/run_user.rb +4 -4
- data/lib/syncwrap/components/ubuntu.rb +11 -9
- data/lib/syncwrap/distro.rb +3 -16
- data/lib/syncwrap/git_help.rb +3 -3
- data/lib/syncwrap/shell.rb +16 -10
- data/sync/etc/sysctl.d/{61-postgresql-shm.conf → 61-postgresql-shm.conf.erb} +1 -1
- data/sync/postgresql/{ubuntu/pg_hba.conf → pg_hba.conf.erb} +15 -3
- data/sync/postgresql/{rhel/postgresql.conf → postgresql.conf.erb} +68 -17
- data/test/test_shell.rb +58 -0
- data/test/test_space_main.rb +1 -1
- metadata +11 -28
- data/sync/postgresql/rhel/pg_hba.conf +0 -87
- data/sync/postgresql/ubuntu/pg_ident.conf +0 -42
- data/sync/postgresql/ubuntu/postgresql.conf +0 -540
- /data/sync/postgresql/{ubuntu/environment → environment} +0 -0
- /data/sync/postgresql/{ubuntu/pg_ctl.conf → pg_ctl.conf} +0 -0
- /data/sync/postgresql/{rhel/pg_ident.conf → pg_ident.conf} +0 -0
- /data/sync/postgresql/{ubuntu/start.conf → start.conf} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a94bbce85319bea7ab7ee215feee79a2f33d2b0
|
4
|
+
data.tar.gz: 8f031221c85ae70474788dfee38e6d5c05e73c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e480edaffd434f726454f2721e95816d085dde7b9114378d49877fe15f0bc7a09bb88b7e61c1fd9c7ce331692fa003e3f237b6e948f94e5d46f93297fc144b29
|
7
|
+
data.tar.gz: 3f4c2eacd8c0e726e91ef71c403c34b5225aaa8c3526d2a6ace7f5c24b8a46af6feabb36ea3d4b903bc59e3405bbfdf239a385d8ac4d0b0b9b9c4f013c5d0c2d
|
data/History.rdoc
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
=== 2.2.0 (2014-7-13)
|
2
|
+
* New SyncWrap::Component#sh :pipefail option to pass bash flag "-o
|
3
|
+
pipefail" to return the first non-zero command return from a
|
4
|
+
pipeline. This option defaults to true when the :error (bash -e)
|
5
|
+
option is also true (the default). You should review pipeline usage
|
6
|
+
in your own components as part of upgrading. Internally, the
|
7
|
+
SyncWrap::Hashdot component required an adjustment for this change.
|
8
|
+
* Major SyncWrap::PostgreSQL component updates. You need to
|
9
|
+
review and adjust any configuration overrides and constructor
|
10
|
+
properties:
|
11
|
+
* Use templates to consolidate RHEL and Ubuntu configuration. Files
|
12
|
+
moved to sync/postgresql. (#2)
|
13
|
+
* Use distro default PG data directory, by default. Tested
|
14
|
+
Amazon Linux EBS MDRaid mount direct to /var/lib/pgsql9. (#3)
|
15
|
+
* No elevated permissions (trust, etc.) by default (#4)
|
16
|
+
* Configuration is 9.3 ready (9.1-9.3 compatible)
|
17
|
+
* Configuration no longer assumes AWS EBS optimizations, relaxed
|
18
|
+
guarantees. See test/aws/sync.rb sample for new PostgreSQL
|
19
|
+
properties to maintain compatibility.
|
20
|
+
* Removed vestigial SyncWrap::Distro package_map and localize package
|
21
|
+
variations to the individual components.
|
22
|
+
* SyncWrap::RunUser now creates a _system_ user/group with default
|
23
|
+
home the same as run_dir.
|
24
|
+
* Add :ebs_mounts AWS profile option to support HVM-style dev mounts,
|
25
|
+
made apparent by EC2 t2 instance types.
|
26
|
+
* Upgrade SyncWrap::JRubyVM default version to 1.7.13
|
27
|
+
* Upgrade SyncWrap::CRubyVM default version to 2.1.2
|
28
|
+
* Upgrade to aws-sdk ~> 1.46 (no longer depends on uuidtools)
|
29
|
+
|
1
30
|
=== 2.1.3 (2014-7-8)
|
2
31
|
* Use sudo instead of --rsync-path=sudo... for :user on localhost
|
3
32
|
* Cleanup the environment for gem_install on different ruby, when
|
data/Manifest.txt
CHANGED
@@ -54,17 +54,14 @@ sync/etc/corosync/uidgid.d/qpid
|
|
54
54
|
sync/etc/init.d/iyyov.erb
|
55
55
|
sync/etc/init.d/qpidd
|
56
56
|
sync/etc/sysconfig/pgsql/postgresql.erb
|
57
|
-
sync/etc/sysctl.d/61-postgresql-shm.conf
|
57
|
+
sync/etc/sysctl.d/61-postgresql-shm.conf.erb
|
58
58
|
sync/jruby/bin/jgem
|
59
|
-
sync/postgresql/
|
60
|
-
sync/postgresql/
|
61
|
-
sync/postgresql/
|
62
|
-
sync/postgresql/
|
63
|
-
sync/postgresql/
|
64
|
-
sync/postgresql/
|
65
|
-
sync/postgresql/ubuntu/pg_ident.conf
|
66
|
-
sync/postgresql/ubuntu/postgresql.conf
|
67
|
-
sync/postgresql/ubuntu/start.conf
|
59
|
+
sync/postgresql/environment
|
60
|
+
sync/postgresql/pg_ctl.conf
|
61
|
+
sync/postgresql/pg_hba.conf.erb
|
62
|
+
sync/postgresql/pg_ident.conf
|
63
|
+
sync/postgresql/postgresql.conf.erb
|
64
|
+
sync/postgresql/start.conf
|
68
65
|
sync/src/hashdot/Makefile.erb
|
69
66
|
sync/src/hashdot/profiles/default.hdp.erb
|
70
67
|
sync/src/hashdot/profiles/jruby-common.hdp
|
data/examples/jruby.rb
CHANGED
data/lib/syncwrap/amazon_ws.rb
CHANGED
@@ -86,11 +86,15 @@ module SyncWrap
|
|
86
86
|
# :security_groups:: As per aws-sdk, but the special :default value
|
87
87
|
# is replaced with a single security group with
|
88
88
|
# same name as the :region.
|
89
|
-
# :ebs_volumes:: The number of EBS volumes to create
|
89
|
+
# :ebs_volumes:: The number of EBS volumes to create and attach to this instance.
|
90
90
|
# :ebs_volume_options:: A nested Hash of options, as per
|
91
91
|
# {AWS::EC2::VolumeCollection.create}[http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/EC2/VolumeCollection.html#create-instance_method]
|
92
92
|
# with custom default :size 16 GB, and the same
|
93
93
|
# :availibility_zone as the instance.
|
94
|
+
# :ebs_mounts:: Device mounting scheme. The value :sdf_p indicates
|
95
|
+
# "/dev/sd[f-p]", and should be used for HVM instances.
|
96
|
+
# The default scheme is currently :sdh1_6 "/dev/sdh[1-6]".
|
97
|
+
# See {EC2: Block Device Mapping}[http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-device-mapping-concepts.html]
|
94
98
|
# :lvm_volumes:: Ignored here.
|
95
99
|
# :roles:: Array of role Strings or Symbols (applied as Roles tag)
|
96
100
|
def aws_create_instance( name, opts = {} )
|
@@ -103,6 +107,7 @@ module SyncWrap
|
|
103
107
|
iopts = opts.dup
|
104
108
|
iopts.delete( :ebs_volumes )
|
105
109
|
iopts.delete( :ebs_volume_options )
|
110
|
+
iopts.delete( :ebs_mounts )
|
106
111
|
iopts.delete( :roles ) #-> tags
|
107
112
|
iopts.delete( :description ) #-> tags
|
108
113
|
iopts.delete( :tag ) #-> tags
|
@@ -150,7 +155,12 @@ module SyncWrap
|
|
150
155
|
attachments = opts[ :ebs_volumes ].times.map do |i|
|
151
156
|
vol = ec2.volumes.create( vopts )
|
152
157
|
wait_until( vol.id, 0.5 ) { vol.status == :available }
|
153
|
-
|
158
|
+
ap = if opts[ :ebs_mounts ] == :sdf_p
|
159
|
+
"/dev/sd" + "fghijklmnop"[i]
|
160
|
+
else
|
161
|
+
"/dev/sdh#{i+1}"
|
162
|
+
end
|
163
|
+
vol.attach_to( inst, ap ) #=> Attachment
|
154
164
|
end
|
155
165
|
|
156
166
|
wait_until( "volumes to attach" ) do
|
data/lib/syncwrap/base.rb
CHANGED
data/lib/syncwrap/component.rb
CHANGED
@@ -172,6 +172,10 @@ module SyncWrap
|
|
172
172
|
# :error:: Pass bash the -e option to terminate early on errors.
|
173
173
|
# Default: true
|
174
174
|
#
|
175
|
+
# :pipefail:: Pass bash the "-o pipefail" option to return the first
|
176
|
+
# non-zero command return from a pipeline.
|
177
|
+
# Default: true when :error is true
|
178
|
+
#
|
175
179
|
# :close:: An additional bash fragment to append after the
|
176
180
|
# provided shell command/fragment and block has been
|
177
181
|
# enqueued. See usage example above. Default: nil
|
@@ -45,7 +45,7 @@ module SyncWrap
|
|
45
45
|
# The ruby version to install, as it appears in source packages
|
46
46
|
# from ruby-lang.org. Note that starting with 2.1.0, the patch
|
47
47
|
# release (p#) no longer appears in package names.
|
48
|
-
# (Default: 2.
|
48
|
+
# (Default: 2.1.2)
|
49
49
|
#
|
50
50
|
# Example values: '2.0.0-p481', '2.1.2'
|
51
51
|
attr_accessor :ruby_version
|
@@ -56,7 +56,7 @@ module SyncWrap
|
|
56
56
|
attr_accessor :do_uninstall_distro_ruby
|
57
57
|
|
58
58
|
def initialize( opts = {} )
|
59
|
-
@ruby_version = "2.
|
59
|
+
@ruby_version = "2.1.2"
|
60
60
|
@do_uninstall_distro_ruby = true
|
61
61
|
|
62
62
|
super
|
@@ -16,6 +16,9 @@
|
|
16
16
|
|
17
17
|
require 'syncwrap/component'
|
18
18
|
|
19
|
+
# For distro class comparison only (pre-load for safety)
|
20
|
+
require 'syncwrap/components/ubuntu'
|
21
|
+
|
19
22
|
module SyncWrap
|
20
23
|
|
21
24
|
# Provision the {Hashdot}[http://hashdot.sourceforge.net/] JVM/script
|
@@ -59,14 +62,21 @@ module SyncWrap
|
|
59
62
|
end
|
60
63
|
|
61
64
|
def install_system_deps
|
62
|
-
|
65
|
+
deps = %w[ make gcc ]
|
66
|
+
deps += if distro.is_a?( Ubuntu )
|
67
|
+
%w[ libapr1 libapr1-dev ]
|
68
|
+
else
|
69
|
+
%w[ apr apr-devel ]
|
70
|
+
end
|
71
|
+
|
72
|
+
dist_install( *deps )
|
63
73
|
end
|
64
74
|
|
65
75
|
def test_hashdot_binary
|
66
76
|
binary = "#{local_root}/bin/hashdot"
|
67
77
|
code,_ = capture( <<-SH, accept: [0,91,92] )
|
68
78
|
if [ -x #{binary} ]; then
|
69
|
-
cver
|
79
|
+
cver=`(#{binary} 2>&1 || true) | grep -o -E '([0-9]\.?){2,}'`
|
70
80
|
if [ "$cver" = "#{hashdot_version}" ]; then
|
71
81
|
exit 0
|
72
82
|
fi
|
@@ -27,11 +27,11 @@ module SyncWrap
|
|
27
27
|
class JRubyVM < Component
|
28
28
|
include RubySupport
|
29
29
|
|
30
|
-
# JRuby version to install (default: 1.7.
|
30
|
+
# JRuby version to install (default: 1.7.13)
|
31
31
|
attr_accessor :jruby_version
|
32
32
|
|
33
33
|
def initialize( opts = {} )
|
34
|
-
@jruby_version = '1.7.
|
34
|
+
@jruby_version = '1.7.13'
|
35
35
|
|
36
36
|
super( { gem_command: 'jgem' }.merge( opts ) )
|
37
37
|
end
|
@@ -22,45 +22,132 @@ require 'syncwrap/components/ubuntu'
|
|
22
22
|
|
23
23
|
module SyncWrap
|
24
24
|
|
25
|
-
# Provisions for install and configuration of PostgreSQL
|
25
|
+
# Provisions for install and configuration of a \PostgreSQL server
|
26
26
|
#
|
27
27
|
# Host component dependencies: <Distro>
|
28
28
|
class PostgreSQL < Component
|
29
29
|
|
30
|
-
#
|
31
|
-
|
30
|
+
# \PostgreSQL _MAJOR.MINOR_ version to install. Since there are
|
31
|
+
# multiple versions in use even for _default_ system packages across
|
32
|
+
# distros, this should be set the same as the version that will
|
33
|
+
# be installed via #package_names. (Default: '9.1')
|
34
|
+
attr_accessor :version
|
32
35
|
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
+
# Return #version as an Array of Integer values
|
37
|
+
def version_a
|
38
|
+
@version.split('.').map( &:to_i )
|
39
|
+
end
|
36
40
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
+
# Location of postgresql data (and possibly also config) directory.
|
42
|
+
# (Default: #pg_default_data_dir)
|
43
|
+
attr_accessor :pg_data_dir
|
44
|
+
|
45
|
+
def pg_data_dir
|
46
|
+
@pg_data_dir || pg_default_data_dir
|
41
47
|
end
|
42
48
|
|
49
|
+
protected
|
50
|
+
|
51
|
+
# The _default_ data dir as used by the distro #package_names.
|
52
|
+
# (Default: as per RHEL or Ubuntu distro packages)
|
53
|
+
attr_writer :pg_default_data_dir
|
54
|
+
|
43
55
|
def pg_default_data_dir
|
44
56
|
@pg_default_data_dir ||
|
45
57
|
case distro
|
46
58
|
when RHEL
|
47
59
|
'/var/lib/pgsql9/data'
|
48
60
|
when Ubuntu
|
49
|
-
|
61
|
+
"/var/lib/postgresql/#{version}/main"
|
50
62
|
else
|
51
63
|
raise ContextError, "Distro #{distro.class.name} not supported"
|
52
64
|
end
|
53
65
|
end
|
54
66
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
67
|
+
# Configuration in the '/etc' directory root?
|
68
|
+
# (Default: true on Ubuntu only, per distro package defaults)
|
69
|
+
attr_writer :pg_specify_etc_config
|
70
|
+
|
71
|
+
def pg_specify_etc_config
|
72
|
+
@pg_specify_etc_config || distro.is_a?( Ubuntu )
|
73
|
+
end
|
74
|
+
|
75
|
+
# The package names, including \PostgreSQL server of the
|
76
|
+
# desired version to install.
|
77
|
+
# (Default: Ubuntu: postgresql-_version_; RHEL: postgresql-server)
|
78
|
+
attr_writer :package_names
|
79
|
+
|
80
|
+
def package_names
|
81
|
+
( @package_names ||
|
82
|
+
( distro.is_a?( Ubuntu ) && [ "postgresql-#{version}" ] ) ||
|
83
|
+
[ "postgresql-server" ] )
|
84
|
+
end
|
85
|
+
|
86
|
+
# The service name of the \PostgreSQL server to start
|
87
|
+
# (Default: 'postgresql' )
|
88
|
+
attr_accessor :service_name
|
89
|
+
|
90
|
+
# Synchronization level for commit
|
91
|
+
# :off may be desirable on high-latency storage (i.e. EBS), at
|
92
|
+
# increased risk. (PG Default: :on)
|
93
|
+
attr_accessor :synchronous_commit
|
94
|
+
|
95
|
+
# Commit delay in microseconds
|
96
|
+
# 10000 or more may be desirable on high-latency storage, at
|
97
|
+
# increased risk. (PG Default: 0 -> none)
|
98
|
+
attr_accessor :commit_delay
|
99
|
+
|
100
|
+
# WAL log segments (16MB each) (PG Default: 3)
|
101
|
+
attr_accessor :checkpoint_segments
|
102
|
+
|
103
|
+
# Shared buffers (Default: '256MB' vs PG: '128MB')
|
104
|
+
attr_accessor :shared_buffers
|
105
|
+
|
106
|
+
# Work memory (Default: '128MB' vs PG: '1MB')
|
107
|
+
attr_accessor :work_mem
|
108
|
+
|
109
|
+
# Maintenance work memory (Default: '128MB' vs PG: '16MB')
|
110
|
+
attr_accessor :maintenance_work_mem
|
111
|
+
|
112
|
+
# Maximum stack depth (Default: '4MB' vs PG: '2MB')
|
113
|
+
attr_accessor :max_stack_depth
|
114
|
+
|
115
|
+
# Concurrent disk I/O operations
|
116
|
+
# May help to use RAID device count or similar (PG Default: 1)
|
117
|
+
attr_accessor :effective_io_concurrency
|
118
|
+
|
119
|
+
# Method used in pg_hba.conf for local (unix socket) access
|
120
|
+
# (PG Default: :peer)
|
121
|
+
attr_accessor :local_access
|
122
|
+
|
123
|
+
# Method used in pg_hba.conf for local network access. Note
|
124
|
+
# that :peer does not work here.
|
125
|
+
# (PG Default: :md5)
|
126
|
+
attr_accessor :local_network_access
|
127
|
+
|
128
|
+
# Method used in pg_hba.conf for network access
|
129
|
+
# :md5 is a common value for password auth.
|
130
|
+
# If truthy, will also set listen_address = '*' in postgresql.conf
|
131
|
+
# (PG Default: false -> no access)
|
132
|
+
attr_accessor :network_access
|
133
|
+
|
134
|
+
# IPv4 address mask for #network_access
|
135
|
+
# (PG Default: nil -> no IPv4 access)
|
136
|
+
attr_accessor :network_v4_mask
|
137
|
+
|
138
|
+
# IPv6 address mask for #network_access
|
139
|
+
# (PG Default: nil -> no IPv4 access)
|
140
|
+
attr_accessor :network_v6_mask
|
141
|
+
|
142
|
+
# Kernel SHMMAX (Shared Memory Maximum) setting to apply.
|
143
|
+
# Note that PostgreSQL 9.3 uses mmap and should not need this.
|
144
|
+
# Currently this is only set on Ubuntu (RHEL packages take care of
|
145
|
+
# it?) (Default: 300MB if #version < 9.3)
|
146
|
+
attr_writer :shared_memory_max
|
147
|
+
|
148
|
+
def shared_memory_max
|
149
|
+
@shared_memory_max ||
|
150
|
+
( ( (version_a <=> [9,3]) < 0 ) && 300_000_000 )
|
64
151
|
end
|
65
152
|
|
66
153
|
def pg_config_dir
|
@@ -68,12 +155,40 @@ module SyncWrap
|
|
68
155
|
when RHEL
|
69
156
|
pg_data_dir
|
70
157
|
when Ubuntu
|
71
|
-
|
158
|
+
"/etc/postgresql/#{version}/main"
|
72
159
|
else
|
73
160
|
raise ContextError, "Distro #{distro.class.name} not supported"
|
74
161
|
end
|
75
162
|
end
|
76
163
|
|
164
|
+
public
|
165
|
+
|
166
|
+
def initialize( opts = {} )
|
167
|
+
@pg_data_dir = nil
|
168
|
+
@pg_default_data_dir = nil
|
169
|
+
@version = '9.1'
|
170
|
+
@package_names = nil
|
171
|
+
@service_name = 'postgresql'
|
172
|
+
@synchronous_commit = :on
|
173
|
+
@commit_delay = 0
|
174
|
+
@checkpoint_segments = 3
|
175
|
+
@shared_buffers = '256MB'
|
176
|
+
@work_mem = '128MB'
|
177
|
+
@maintenance_work_mem = '128MB'
|
178
|
+
@max_stack_depth = '4MB'
|
179
|
+
@effective_io_concurrency = 1
|
180
|
+
@local_access = :peer
|
181
|
+
@local_network_access = :md5
|
182
|
+
@network_access = false
|
183
|
+
@network_v4_mask = nil
|
184
|
+
@network_v6_mask = nil
|
185
|
+
@shared_memory_max = nil
|
186
|
+
super
|
187
|
+
end
|
188
|
+
|
189
|
+
# Calls in order: #package_install, #setup_data_dir, and
|
190
|
+
# #pg_configure then ensures the server is running (via #pg_start) or
|
191
|
+
# is restarted (via #pg_restart) if there were configuration changes.
|
77
192
|
def install
|
78
193
|
package_install
|
79
194
|
changes = setup_data_dir
|
@@ -83,17 +198,24 @@ module SyncWrap
|
|
83
198
|
else
|
84
199
|
pg_restart
|
85
200
|
end
|
201
|
+
changes
|
86
202
|
end
|
87
203
|
|
204
|
+
# Install the #package_names. In the Ubuntu case, also install any
|
205
|
+
# #shared_memory_max adjustment and stops the server for subsequent
|
206
|
+
# reconfigure or data relocation.
|
88
207
|
def package_install
|
89
|
-
dist_install
|
208
|
+
dist_install( *package_names )
|
90
209
|
if distro.is_a?( Ubuntu )
|
91
210
|
pg_stop
|
92
|
-
|
93
|
-
|
211
|
+
if shared_memory_max
|
212
|
+
rput( 'etc/sysctl.d/61-postgresql-shm.conf', user: :root )
|
213
|
+
sudo "sysctl -p /etc/sysctl.d/61-postgresql-shm.conf"
|
214
|
+
end
|
94
215
|
end
|
95
216
|
end
|
96
217
|
|
218
|
+
# Initialize or move the server data directory as per #pg_data_dir.
|
97
219
|
def setup_data_dir
|
98
220
|
changes = []
|
99
221
|
|
@@ -101,20 +223,16 @@ module SyncWrap
|
|
101
223
|
|
102
224
|
when RHEL
|
103
225
|
unless pg_data_dir == pg_default_data_dir
|
104
|
-
changes = rput( 'etc/sysconfig/pgsql/postgresql', :
|
226
|
+
changes = rput( 'etc/sysconfig/pgsql/postgresql', user: :root )
|
105
227
|
end
|
106
228
|
|
107
229
|
sudo( "if [ ! -d '#{pg_data_dir}/base' ]; then", close: "fi" ) do
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
chmod 700 #{pg_data_dir}
|
115
|
-
SH
|
116
|
-
end
|
117
|
-
dist_service( 'postgresql', 'initdb' )
|
230
|
+
sudo <<-SH
|
231
|
+
mkdir -p #{pg_data_dir}
|
232
|
+
chown postgres:postgres #{pg_data_dir}
|
233
|
+
chmod 700 #{pg_data_dir}
|
234
|
+
SH
|
235
|
+
dist_service( service_name, 'initdb' )
|
118
236
|
end
|
119
237
|
|
120
238
|
when Ubuntu
|
@@ -133,25 +251,27 @@ module SyncWrap
|
|
133
251
|
changes
|
134
252
|
end
|
135
253
|
|
136
|
-
# Update PostgreSQL
|
254
|
+
# Update the \PostgreSQL configuration files
|
137
255
|
def pg_configure
|
138
|
-
|
139
|
-
if
|
140
|
-
|
141
|
-
|
142
|
-
changes
|
256
|
+
files = %w[ pg_hba.conf pg_ident.conf postgresql.conf ]
|
257
|
+
files += %w[ environment pg_ctl.conf ] if distro.is_a?( Ubuntu )
|
258
|
+
files = files.map { |f| File.join( 'postgresql', f ) }
|
259
|
+
rput( *files, pg_config_dir, user: 'postgres' )
|
143
260
|
end
|
144
261
|
|
262
|
+
# Start the server
|
145
263
|
def pg_start
|
146
|
-
dist_service(
|
264
|
+
dist_service( service_name, 'start' )
|
147
265
|
end
|
148
266
|
|
267
|
+
# Restart the server
|
149
268
|
def pg_restart
|
150
|
-
dist_service(
|
269
|
+
dist_service( service_name, 'restart' )
|
151
270
|
end
|
152
271
|
|
272
|
+
# Stop the server
|
153
273
|
def pg_stop
|
154
|
-
dist_service(
|
274
|
+
dist_service( service_name, 'stop' )
|
155
275
|
end
|
156
276
|
|
157
277
|
end
|
@@ -27,20 +27,18 @@ module SyncWrap
|
|
27
27
|
|
28
28
|
def initialize( opts = {} )
|
29
29
|
super
|
30
|
-
|
31
|
-
packages_map.merge!( 'emacs' => 'emacs-nox',
|
32
|
-
'postgresql' => 'postgresql-server' )
|
33
30
|
end
|
34
31
|
|
35
|
-
# Install
|
36
|
-
#
|
32
|
+
# Install the specified package names. A trailing hash is
|
33
|
+
# interpreted as options, see below.
|
37
34
|
#
|
38
35
|
# ==== Options
|
39
36
|
# :succeed:: Always succeed (useful for local rpm files which
|
40
|
-
#
|
37
|
+
# might already be installed.)
|
38
|
+
#
|
39
|
+
# Other options will be ignored.
|
41
40
|
def dist_install( *pkgs )
|
42
41
|
opts = pkgs.last.is_a?( Hash ) && pkgs.pop || {}
|
43
|
-
pkgs = dist_map_packages( pkgs )
|
44
42
|
|
45
43
|
if opts[ :succeed ]
|
46
44
|
sudo "yum install -q -y #{pkgs.join( ' ' )} || true"
|
@@ -49,19 +47,23 @@ module SyncWrap
|
|
49
47
|
end
|
50
48
|
end
|
51
49
|
|
50
|
+
# Uninstall the specified package names.
|
52
51
|
def dist_uninstall( *pkgs )
|
53
|
-
pkgs = dist_map_packages( pkgs )
|
54
52
|
sudo "yum remove -q -y #{pkgs.join( ' ' )}"
|
55
53
|
end
|
56
54
|
|
55
|
+
# Install a System V style init.d service script
|
57
56
|
def dist_install_init_service( name )
|
58
57
|
sudo "/sbin/chkconfig --add #{name}"
|
59
58
|
end
|
60
59
|
|
60
|
+
# Enable the System V style init.d service
|
61
61
|
def dist_enable_init_service( name )
|
62
62
|
sudo "/sbin/chkconfig #{name} on"
|
63
63
|
end
|
64
64
|
|
65
|
+
# Run via sudo, the service command typically supporting 'start',
|
66
|
+
# 'stop', 'restart', 'status', etc. arguments.
|
65
67
|
def dist_service( *args )
|
66
68
|
sudo( [ '/sbin/service', *args ].join( ' ' ) )
|
67
69
|
end
|
@@ -37,11 +37,11 @@ module SyncWrap
|
|
37
37
|
end
|
38
38
|
|
39
39
|
# Home directory for the #run_user
|
40
|
-
# (default: nil ->
|
40
|
+
# (default: nil -> same as #run_dir)
|
41
41
|
attr_writer :run_user_home
|
42
42
|
|
43
43
|
def run_user_home
|
44
|
-
@run_user_home
|
44
|
+
@run_user_home || run_dir
|
45
45
|
end
|
46
46
|
|
47
47
|
def initialize( opts = {} )
|
@@ -60,10 +60,10 @@ module SyncWrap
|
|
60
60
|
# Create run_user if not already present
|
61
61
|
def create_run_user
|
62
62
|
sudo( "if ! id #{run_user} >/dev/null 2>&1; then", close: "fi" ) do
|
63
|
-
user_opts = "-c 'Run User' -s /bin/bash"
|
63
|
+
user_opts = "-r -c 'Run User' -s /bin/bash"
|
64
64
|
user_opts += " -d #{run_user_home}" if run_user_home
|
65
65
|
if run_group && run_group != run_user
|
66
|
-
sudo "groupadd -f #{run_group}"
|
66
|
+
sudo "groupadd -r -f #{run_group}"
|
67
67
|
user_opts += " -g #{run_group}"
|
68
68
|
end
|
69
69
|
sudo "useradd #{user_opts} #{run_user}"
|
@@ -19,46 +19,48 @@ require 'syncwrap/distro'
|
|
19
19
|
|
20
20
|
module SyncWrap
|
21
21
|
|
22
|
-
# Customizations for Ubuntu and possibly other Debian/apt packaged
|
22
|
+
# Customizations for \Ubuntu and possibly other Debian/apt packaged
|
23
23
|
# derivatives. Specific distros/versions may further specialize.
|
24
24
|
class Ubuntu < Component
|
25
25
|
include SyncWrap::Distro
|
26
26
|
|
27
27
|
def initialize( opts = {} )
|
28
28
|
super
|
29
|
-
|
30
|
-
packages_map.merge!( 'apr' => 'libapr1',
|
31
|
-
'apr-devel' => 'libapr1-dev' )
|
32
29
|
end
|
33
30
|
|
34
|
-
# Install
|
35
|
-
# host, an "apt-get update" is issued as
|
36
|
-
# interpreted as options, see below.
|
31
|
+
# Install the specified package names. The first time this is
|
32
|
+
# applied to any given host, an "apt-get update" is issued as
|
33
|
+
# well. A trailing hash is interpreted as options, see below.
|
37
34
|
#
|
38
35
|
# ==== Options
|
39
36
|
# :minimal:: Eqv to --no-install-recommends
|
37
|
+
#
|
38
|
+
# Other options will be ignored.
|
40
39
|
def dist_install( *args )
|
41
40
|
opts = args.last.is_a?( Hash ) && args.pop || {}
|
42
|
-
args = dist_map_packages( args )
|
43
41
|
args.unshift "--no-install-recommends" if opts[ :minimal ]
|
44
42
|
|
45
43
|
sudo( "apt-get -yqq update" ) if first_apt?
|
46
44
|
sudo( "apt-get -yq install #{args.join ' '}" )
|
47
45
|
end
|
48
46
|
|
47
|
+
# Uninstall the specified package names.
|
49
48
|
def dist_uninstall( *pkgs )
|
50
|
-
pkgs = dist_map_packages( pkgs )
|
51
49
|
sudo "aptitude -yq purge #{pkgs.join ' '}"
|
52
50
|
end
|
53
51
|
|
52
|
+
# Install a System V style init.d service script
|
54
53
|
def dist_install_init_service( name )
|
55
54
|
sudo "/usr/sbin/update-rc.d #{name} defaults"
|
56
55
|
end
|
57
56
|
|
57
|
+
# Enable the System V style init.d service
|
58
58
|
def dist_enable_init_service( name )
|
59
59
|
sudo "/usr/sbin/update-rc.d #{name} enable"
|
60
60
|
end
|
61
61
|
|
62
|
+
# Run via sudo, the service command typically supporting 'start',
|
63
|
+
# 'stop', 'restart', 'status', etc. arguments.
|
62
64
|
def dist_service( *args )
|
63
65
|
sudo( [ '/usr/sbin/service', *args ].join( ' ' ) )
|
64
66
|
end
|