syncwrap 1.5.2 → 2.0.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 +7 -0
- data/History.rdoc +19 -0
- data/Manifest.txt +82 -34
- data/README.rdoc +96 -48
- data/Rakefile +0 -65
- data/bin/syncwrap +27 -0
- data/examples/LAYOUT.rdoc +70 -0
- data/examples/Rakefile +16 -0
- data/examples/ec2.rb +44 -0
- data/examples/hello.rb +14 -0
- data/examples/hello_binding.rb +27 -0
- data/examples/jruby.rb +11 -0
- data/examples/private/aws.json +4 -0
- data/examples/rput.rb +24 -0
- data/examples/sync/home/bob/.ssh/authorized_keys +1 -0
- data/examples/sync/tmp/sample.erb +3 -0
- data/lib/syncwrap/amazon_ec2.rb +236 -0
- data/lib/syncwrap/amazon_ws.rb +308 -0
- data/lib/syncwrap/base.rb +4 -2
- data/lib/syncwrap/cli.rb +328 -0
- data/lib/syncwrap/component.rb +443 -0
- data/lib/syncwrap/components/commercial_jdk.rb +76 -0
- data/lib/syncwrap/components/cruby_vm.rb +144 -0
- data/lib/syncwrap/components/etc_hosts.rb +44 -0
- data/lib/syncwrap/{geminabox.rb → components/geminabox.rb} +12 -17
- data/lib/syncwrap/components/hashdot.rb +97 -0
- data/lib/syncwrap/components/iyyov.rb +144 -0
- data/lib/syncwrap/components/iyyov_daemon.rb +125 -0
- data/lib/syncwrap/components/jruby_vm.rb +122 -0
- data/lib/syncwrap/components/mdraid.rb +204 -0
- data/lib/syncwrap/components/network.rb +99 -0
- data/lib/syncwrap/components/open_jdk.rb +70 -0
- data/lib/syncwrap/components/postgresql.rb +159 -0
- data/lib/syncwrap/components/qpid.rb +303 -0
- data/lib/syncwrap/components/rhel.rb +71 -0
- data/lib/syncwrap/components/run_user.rb +99 -0
- data/lib/syncwrap/components/ubuntu.rb +85 -0
- data/lib/syncwrap/components/users.rb +200 -0
- data/lib/syncwrap/context.rb +260 -0
- data/lib/syncwrap/distro.rb +53 -60
- data/lib/syncwrap/formatter.rb +149 -0
- data/lib/syncwrap/host.rb +134 -0
- data/lib/syncwrap/main.rb +62 -0
- data/lib/syncwrap/path_util.rb +55 -0
- data/lib/syncwrap/rsync.rb +227 -0
- data/lib/syncwrap/ruby_support.rb +110 -0
- data/lib/syncwrap/shell.rb +207 -0
- data/lib/syncwrap.rb +367 -1
- data/{etc → sync/etc}/gemrc +1 -3
- data/sync/etc/hosts.erb +8 -0
- data/{etc/init.d/iyyov → sync/etc/init.d/iyyov.erb} +35 -7
- data/sync/etc/sysconfig/pgsql/postgresql.erb +2 -0
- data/sync/src/hashdot/Makefile.erb +98 -0
- data/sync/src/hashdot/profiles/default.hdp.erb +25 -0
- data/sync/src/hashdot/profiles/jruby-common.hdp +28 -0
- data/sync/src/hashdot/profiles/jruby-shortlived.hdp +9 -0
- data/sync/src/hashdot/profiles/jruby.hdp.erb +13 -0
- data/sync/src/hashdot/profiles/shortlived.hdp +6 -0
- data/sync/var/iyyov/default/config.rb +1 -0
- data/sync/var/iyyov/default/daemon.rb.erb +15 -0
- data/sync/var/iyyov/jobs.rb.erb +4 -0
- data/test/muddled_sync.rb +13 -0
- data/test/setup.rb +39 -0
- data/test/sync/d1/bar +1 -0
- data/test/sync/d1/foo.erb +1 -0
- data/test/sync/d3/d2/bar +1 -0
- data/test/sync/d3/d2/foo.erb +1 -0
- data/test/test_components.rb +108 -0
- data/test/test_context.rb +107 -0
- data/test/test_context_rput.rb +289 -0
- data/test/test_rsync.rb +138 -0
- data/test/test_shell.rb +233 -0
- data/test/test_space.rb +218 -0
- data/test/test_space_main.rb +40 -0
- data/test/zfile +1 -0
- metadata +204 -71
- data/etc/sysconfig/pgsql/postgresql +0 -2
- data/lib/syncwrap/aws.rb +0 -448
- data/lib/syncwrap/common.rb +0 -161
- data/lib/syncwrap/ec2.rb +0 -59
- data/lib/syncwrap/hashdot.rb +0 -70
- data/lib/syncwrap/iyyov.rb +0 -139
- data/lib/syncwrap/java.rb +0 -61
- data/lib/syncwrap/jruby.rb +0 -118
- data/lib/syncwrap/postgresql.rb +0 -135
- data/lib/syncwrap/qpid.rb +0 -251
- data/lib/syncwrap/remote_task.rb +0 -199
- data/lib/syncwrap/rhel.rb +0 -67
- data/lib/syncwrap/ubuntu.rb +0 -78
- data/lib/syncwrap/user_run.rb +0 -102
- data/test/test_syncwrap.rb +0 -202
- data/var/iyyov/jobs.rb +0 -11
- /data/{etc → sync/etc}/corosync/corosync.conf +0 -0
- /data/{etc → sync/etc}/corosync/uidgid.d/qpid +0 -0
- /data/{etc → sync/etc}/init.d/qpidd +0 -0
- /data/{etc → sync/etc}/sysctl.d/61-postgresql-shm.conf +0 -0
- /data/{usr/local → sync/jruby}/bin/jgem +0 -0
- /data/{postgresql → sync/postgresql}/rhel/pg_hba.conf +0 -0
- /data/{postgresql → sync/postgresql}/rhel/pg_ident.conf +0 -0
- /data/{postgresql → sync/postgresql}/rhel/postgresql.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/environment +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/pg_ctl.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/pg_hba.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/pg_ident.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/postgresql.conf +0 -0
- /data/{postgresql → sync/postgresql}/ubuntu/start.conf +0 -0
- /data/{usr → sync/usr}/local/etc/qpidd.conf +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
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/components/rhel'
|
|
19
|
+
|
|
20
|
+
module SyncWrap
|
|
21
|
+
|
|
22
|
+
# Qpid AMQP broker provisioning. Currently this is RHEL (CentoOS,
|
|
23
|
+
# Amazon Linux) centric; it has not been ported to Debian/Ubuntu.
|
|
24
|
+
#
|
|
25
|
+
# Host component dependencies: RHEL
|
|
26
|
+
class Qpid < Component
|
|
27
|
+
|
|
28
|
+
# Root directory for src and build
|
|
29
|
+
# (Default: /tmp/src)
|
|
30
|
+
attr_accessor :qpid_src_root
|
|
31
|
+
|
|
32
|
+
# The qpidd version to build, install
|
|
33
|
+
attr_accessor :qpid_version
|
|
34
|
+
|
|
35
|
+
# Base HTTP url to qpid source repo.
|
|
36
|
+
attr_accessor :qpid_repo
|
|
37
|
+
|
|
38
|
+
# Output package naming modifier, i.e. "amzn1"
|
|
39
|
+
attr_accessor :qpid_distro
|
|
40
|
+
|
|
41
|
+
# Distro package base name for boost. On Amazon Linux you may want
|
|
42
|
+
# to set this to "boost141", depending on the qpid version.
|
|
43
|
+
# (Default: "boost")
|
|
44
|
+
attr_accessor :boost_pkg
|
|
45
|
+
|
|
46
|
+
# Corosync version to build, isntall
|
|
47
|
+
# (Default: '1.4.4')
|
|
48
|
+
attr_accessor :corosync_version
|
|
49
|
+
|
|
50
|
+
# Base HTTP url to corosync source repo.
|
|
51
|
+
attr_accessor :corosync_repo
|
|
52
|
+
|
|
53
|
+
def initialize( opt = {} )
|
|
54
|
+
@qpid_src_root = '/tmp/src'
|
|
55
|
+
|
|
56
|
+
@qpid_version = '0.24'
|
|
57
|
+
@qpid_repo = 'http://archive.us.apache.org/dist/qpid'
|
|
58
|
+
# FIXME: Usable only for the newest builds
|
|
59
|
+
# @qpid_repo = 'http://apache.osuosl.org/qpid'
|
|
60
|
+
@qpid_distro = 'amzn1'
|
|
61
|
+
|
|
62
|
+
@boost_pkg = 'boost'
|
|
63
|
+
|
|
64
|
+
@corosync_version = '1.4.4'
|
|
65
|
+
@corosync_repo = 'http://corosync.org/download'
|
|
66
|
+
super
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def install
|
|
70
|
+
unless distro.kind_of?( RHEL )
|
|
71
|
+
raise ContextError, "#{distro.class} unsupported"
|
|
72
|
+
end
|
|
73
|
+
qpid_install
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def qpid_install
|
|
77
|
+
unless test_qpidd_version
|
|
78
|
+
qpid_install!
|
|
79
|
+
qpid_install_init!
|
|
80
|
+
end
|
|
81
|
+
qpid_tools_install
|
|
82
|
+
rput( 'usr/local/etc/qpidd.conf', user: :root )
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_qpidd_version
|
|
86
|
+
bin = "/usr/local/sbin/qpidd"
|
|
87
|
+
code,_ = capture( <<-SH, accept:[0,91,92] )
|
|
88
|
+
if [ -x #{bin} ]; then
|
|
89
|
+
ver=`#{bin} --version | grep -o -E '[0-9]+(\.[0-9]+)+$'`
|
|
90
|
+
if [ "$ver" = "#{qpid_version}" ]; then
|
|
91
|
+
exit 0
|
|
92
|
+
fi
|
|
93
|
+
exit 92
|
|
94
|
+
fi
|
|
95
|
+
exit 91
|
|
96
|
+
SH
|
|
97
|
+
(code == 0)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def qpid_install_init!
|
|
101
|
+
sudo <<-SH
|
|
102
|
+
if ! id qpidd >/dev/null 2>&1; then
|
|
103
|
+
useradd -r qpidd
|
|
104
|
+
fi
|
|
105
|
+
mkdir -p /var/local/qpidd
|
|
106
|
+
chown qpidd:qpidd /var/local/qpidd
|
|
107
|
+
SH
|
|
108
|
+
|
|
109
|
+
rput( 'etc/init.d/qpidd', user: :root )
|
|
110
|
+
|
|
111
|
+
# Add to init.d
|
|
112
|
+
dist_install_init_service( 'qpidd' )
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def qpid_tools_install
|
|
116
|
+
unless exist?( "/usr/bin/qpid-config" )
|
|
117
|
+
qpid_tools_install!
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def qpid_install!
|
|
122
|
+
corosync_install!( devel: true )
|
|
123
|
+
qpid_build
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def corosync_install( opts = {} )
|
|
127
|
+
unless exist?( "/usr/sbin/corosync" )
|
|
128
|
+
corosync_install!( opts )
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def corosync_install!( opts = {} )
|
|
133
|
+
corosync_build
|
|
134
|
+
dist_install( "#{corosync_src}/x86_64/*.rpm", succeed: true )
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def qpid_tools_install!
|
|
138
|
+
dist_install( 'python-setuptools' )
|
|
139
|
+
qpid_src = "#{qpid_src_root}/qpid-#{qpid_version}"
|
|
140
|
+
|
|
141
|
+
sh <<-SH
|
|
142
|
+
mkdir -p #{qpid_src_root}
|
|
143
|
+
rm -rf #{qpid_src}
|
|
144
|
+
cd #{qpid_src_root}
|
|
145
|
+
curl -sSL #{qpid_tools_tarball} | tar -zxf -
|
|
146
|
+
SH
|
|
147
|
+
|
|
148
|
+
sudo <<-SH
|
|
149
|
+
cd #{qpid_src}
|
|
150
|
+
easy_install ./python ./tools ./extras/qmf
|
|
151
|
+
SH
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
protected
|
|
155
|
+
|
|
156
|
+
def qpid_build
|
|
157
|
+
qpid_install_build_deps
|
|
158
|
+
qpid_install_deps
|
|
159
|
+
|
|
160
|
+
qpid_src = "#{qpid_src_root}/qpidc-#{qpid_version}"
|
|
161
|
+
|
|
162
|
+
sh <<-SH
|
|
163
|
+
mkdir -p #{qpid_src_root}
|
|
164
|
+
rm -rf #{qpid_src}
|
|
165
|
+
cd #{qpid_src_root}
|
|
166
|
+
curl -sSL #{qpid_src_tarball} | tar -zxf -
|
|
167
|
+
cd #{qpid_src}
|
|
168
|
+
./configure --enable-deprecated-autotools #{redirect?}
|
|
169
|
+
make #{redirect?}
|
|
170
|
+
SH
|
|
171
|
+
|
|
172
|
+
sudo <<-SH
|
|
173
|
+
cd #{qpid_src}
|
|
174
|
+
make install #{redirect?}
|
|
175
|
+
make check #{redirect?}
|
|
176
|
+
cd /usr/local
|
|
177
|
+
rm -f /tmp/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz
|
|
178
|
+
tar -zc \
|
|
179
|
+
--exclude games --exclude lib64/perl5 --exclude src \
|
|
180
|
+
--exclude share/man --exclude share/perl5 --exclude share/info \
|
|
181
|
+
--exclude share/applications \
|
|
182
|
+
-f /tmp/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz .
|
|
183
|
+
SH
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def qpid_src_tarball
|
|
187
|
+
"#{qpid_repo}/#{qpid_version}/qpid-cpp-#{qpid_version}.tar.gz"
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def qpid_tools_tarball
|
|
191
|
+
"#{qpid_repo}/#{qpid_version}/qpid-#{qpid_version}.tar.gz"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def qpid_install_build_deps
|
|
195
|
+
dist_install( %w[ gcc gcc-c++ make autogen autoconf
|
|
196
|
+
help2man libtool pkgconfig rpm-build ] )
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def qpid_install_deps
|
|
200
|
+
dist_install( [ "#{boost_pkg}-devel" ] +
|
|
201
|
+
%w[ nss-devel libuuid-devel swig
|
|
202
|
+
ruby-devel python-devel
|
|
203
|
+
cyrus-sasl-devel cyrus-sasl-plain cyrus-sasl-md5 ] )
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def corosync_build
|
|
207
|
+
qpid_install_build_deps
|
|
208
|
+
corosync_install_build_deps
|
|
209
|
+
|
|
210
|
+
sh <<-SH
|
|
211
|
+
mkdir -p #{qpid_src_root}
|
|
212
|
+
rm -rf #{corosync_src}
|
|
213
|
+
cd #{qpid_src_root}
|
|
214
|
+
curl -sSL #{corosync_repo}/corosync-#{corosync_version}.tar.gz | tar -zxf -
|
|
215
|
+
cd #{corosync_src}
|
|
216
|
+
./autogen.sh #{redirect?}
|
|
217
|
+
./configure #{redirect?}
|
|
218
|
+
make rpm #{redirect?}
|
|
219
|
+
SH
|
|
220
|
+
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def corosync_packages( include_devel = false )
|
|
224
|
+
packs = [ "corosync-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm",
|
|
225
|
+
"corosynclib-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm" ]
|
|
226
|
+
packs << "corosynclib-devel-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm" if include_devel
|
|
227
|
+
packs
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def corosync_install_build_deps
|
|
231
|
+
dist_install( %w[ nss-devel libibverbs-devel librdmacm-devel ] )
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def corosync_src
|
|
235
|
+
"#{qpid_src_root}/corosync-#{corosync_version}"
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def exist?( file )
|
|
239
|
+
code,_ = capture( "test -e #{file}", accept:[0,1] )
|
|
240
|
+
(code == 0)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
def redirect?
|
|
244
|
+
verbose? ? "" : ">/dev/null"
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Simplify qpid install by using pre-built binaries (for example,
|
|
250
|
+
# archived from the build in Qpid)
|
|
251
|
+
#
|
|
252
|
+
# Host component dependencies: RHEL
|
|
253
|
+
class QpidRepo < Qpid
|
|
254
|
+
|
|
255
|
+
attr_accessor :qpid_prebuild_repo
|
|
256
|
+
|
|
257
|
+
def initialize( opt = {} )
|
|
258
|
+
@qpid_prebuild_repo = nil
|
|
259
|
+
super
|
|
260
|
+
raise "qpid_prebuild_repo required, but not set" unless qpid_prebuild_repo
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def qpid_install
|
|
264
|
+
corosync_install
|
|
265
|
+
super
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def qpid_install!
|
|
269
|
+
|
|
270
|
+
dist_install( [ boost_pkg, 'cyrus-sasl' ] )
|
|
271
|
+
|
|
272
|
+
sudo <<-SH
|
|
273
|
+
cd /usr/local
|
|
274
|
+
curl -sS #{qpid_prebuild_repo}/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz | tar -zxf -
|
|
275
|
+
SH
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def corosync_install!( opts = {} )
|
|
279
|
+
packs = corosync_packages
|
|
280
|
+
curls = packs.map do |p|
|
|
281
|
+
"curl -sS -O #{qpid_prebuild_repo}/#{p}"
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
sudo <<-SH
|
|
285
|
+
rm -rf /tmp/rpm-drop
|
|
286
|
+
mkdir -p /tmp/rpm-drop
|
|
287
|
+
cd /tmp/rpm-drop
|
|
288
|
+
#{curls.join("\n")}
|
|
289
|
+
SH
|
|
290
|
+
dist_install( "/tmp/rpm-drop/*.rpm", succeed: true )
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
protected
|
|
294
|
+
|
|
295
|
+
# Where uploaded qpid-python-tools-M.N.tar.gz contains the
|
|
296
|
+
# ./python ./tools ./extras/qmf packages for easy_install.
|
|
297
|
+
def qpid_tools_tarball
|
|
298
|
+
"#{qpid_prebuild_repo}/qpid-python-tools-#{qpid_version}.tar.gz"
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
|
|
20
|
+
module SyncWrap
|
|
21
|
+
|
|
22
|
+
# Customizations for RedHat Enterprise Linux and derivatives like
|
|
23
|
+
# CentOS and Amazon Linux. Specific distros/versions may further
|
|
24
|
+
# override these.
|
|
25
|
+
class RHEL < Component
|
|
26
|
+
include SyncWrap::Distro
|
|
27
|
+
|
|
28
|
+
def initialize( opts = {} )
|
|
29
|
+
super
|
|
30
|
+
|
|
31
|
+
packages_map.merge!( 'emacs' => 'emacs-nox',
|
|
32
|
+
'postgresql' => 'postgresql-server' )
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Install packages.
|
|
36
|
+
# A trailing hash is interpreted as options, see below.
|
|
37
|
+
#
|
|
38
|
+
# ==== Options
|
|
39
|
+
# :succeed:: Always succeed (useful for local rpm files which
|
|
40
|
+
# might already be installed.)
|
|
41
|
+
def dist_install( *pkgs )
|
|
42
|
+
opts = pkgs.last.is_a?( Hash ) && pkgs.pop || {}
|
|
43
|
+
pkgs = dist_map_packages( pkgs )
|
|
44
|
+
|
|
45
|
+
if opts[ :succeed ]
|
|
46
|
+
sudo "yum install -q -y #{pkgs.join( ' ' )} || true"
|
|
47
|
+
else
|
|
48
|
+
sudo "yum install -q -y #{pkgs.join( ' ' )}"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def dist_uninstall( *pkgs )
|
|
53
|
+
pkgs = dist_map_packages( pkgs )
|
|
54
|
+
sudo "yum remove -q -y #{pkgs.join( ' ' )}"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def dist_install_init_service( name )
|
|
58
|
+
sudo "/sbin/chkconfig --add #{name}"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def dist_enable_init_service( name )
|
|
62
|
+
sudo "/sbin/chkconfig #{name} on"
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def dist_service( *args )
|
|
66
|
+
sudo( [ '/sbin/service', *args ].join( ' ' ) )
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
|
|
19
|
+
module SyncWrap
|
|
20
|
+
|
|
21
|
+
# Provision a user to run daemons within a run directory. Utilities
|
|
22
|
+
# for working with the same.
|
|
23
|
+
class RunUser < Component
|
|
24
|
+
|
|
25
|
+
# A user for running deployed daemons, jobs (default: 'runr')
|
|
26
|
+
attr_accessor :run_user
|
|
27
|
+
|
|
28
|
+
# A group for running (default: nil -> same as run_user)
|
|
29
|
+
attr_accessor :run_group
|
|
30
|
+
|
|
31
|
+
# Root directory for persistent data and logs
|
|
32
|
+
# (default: /var/local/#{run_user})
|
|
33
|
+
attr_writer :run_dir
|
|
34
|
+
|
|
35
|
+
def run_dir
|
|
36
|
+
@run_dir || "/var/local/#{run_user}"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize( opts = {} )
|
|
40
|
+
@run_user = 'runr'
|
|
41
|
+
@run_group = nil
|
|
42
|
+
@run_dir = nil
|
|
43
|
+
|
|
44
|
+
super
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def install
|
|
48
|
+
create_run_user
|
|
49
|
+
create_run_dir
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Create run_user if not already present
|
|
53
|
+
def create_run_user
|
|
54
|
+
sudo( "if ! id #{run_user} >/dev/null 2>&1; then", close: "fi" ) do
|
|
55
|
+
if run_group && run_group != run_user
|
|
56
|
+
sudo <<-SH
|
|
57
|
+
groupadd -f #{run_group}
|
|
58
|
+
useradd -g #{run_group} #{run_user}
|
|
59
|
+
SH
|
|
60
|
+
else
|
|
61
|
+
sudo "useradd #{run_user}"
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Create and set owner/permission of run_dir, such that run_user may
|
|
67
|
+
# create new directories there.
|
|
68
|
+
def create_run_dir
|
|
69
|
+
make_dir( run_dir )
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def service_dir( sname, instance = nil )
|
|
73
|
+
run_dir + '/' + [ sname, instance ].compact.join( '-' )
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Create and set owner/permission of a named service directory under
|
|
77
|
+
# run_dir.
|
|
78
|
+
def create_service_dir( sname, instance = nil )
|
|
79
|
+
sdir = service_dir( sname, instance )
|
|
80
|
+
make_dir( sdir )
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def make_dir( dir )
|
|
84
|
+
sudo "mkdir -p #{dir}"
|
|
85
|
+
chown_run_user dir
|
|
86
|
+
sudo "chmod 775 #{dir}"
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Chown to user:run_group where args may be flags and files/directories.
|
|
90
|
+
def chown_run_user( *args )
|
|
91
|
+
flags, paths = args.partition { |a| a =~ /^-/ }
|
|
92
|
+
sudo( [ 'chown', flags,
|
|
93
|
+
[ run_user, run_group || run_user ].join(':'),
|
|
94
|
+
paths ].flatten.compact.join( ' ' ) )
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
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 'thread'
|
|
20
|
+
|
|
21
|
+
module SyncWrap
|
|
22
|
+
|
|
23
|
+
# Customizations for Ubuntu and possibly other Debian/apt packaged
|
|
24
|
+
# derivatives. Specific distros/versions may further specialize.
|
|
25
|
+
class Ubuntu < Component
|
|
26
|
+
include SyncWrap::Distro
|
|
27
|
+
|
|
28
|
+
def initialize( opts = {} )
|
|
29
|
+
@apt_update_state_lock = Mutex.new
|
|
30
|
+
@apt_update_state = {}
|
|
31
|
+
|
|
32
|
+
super
|
|
33
|
+
|
|
34
|
+
packages_map.merge!( 'apr' => 'libapr1',
|
|
35
|
+
'apr-devel' => 'libapr1-dev' )
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Install packages. The first time this is applied to any given
|
|
39
|
+
# host, an "apt-get update" is issued as well. A trailing hash is
|
|
40
|
+
# interpreted as options, see below.
|
|
41
|
+
#
|
|
42
|
+
# ==== Options
|
|
43
|
+
# :minimal:: Eqv to --no-install-recommends
|
|
44
|
+
def dist_install( *args )
|
|
45
|
+
opts = args.last.is_a?( Hash ) && args.pop || {}
|
|
46
|
+
args = dist_map_packages( args )
|
|
47
|
+
args.unshift "--no-install-recommends" if opts[ :minimal ]
|
|
48
|
+
|
|
49
|
+
sudo( "apt-get -yqq update" ) if first_apt?
|
|
50
|
+
sudo( "apt-get -yq install #{args.join ' '}" )
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def dist_uninstall( *pkgs )
|
|
54
|
+
pkgs = dist_map_packages( pkgs )
|
|
55
|
+
sudo "aptitude -yq purge #{pkgs.join ' '}"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def dist_install_init_service( name )
|
|
59
|
+
sudo "/usr/sbin/update-rc.d #{name} defaults"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def dist_enable_init_service( name )
|
|
63
|
+
sudo "/usr/sbin/update-rc.d #{name} enable"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def dist_service( *args )
|
|
67
|
+
sudo( [ '/usr/sbin/service', *args ].join( ' ' ) )
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
protected
|
|
71
|
+
|
|
72
|
+
def first_apt?
|
|
73
|
+
@apt_update_state_lock.synchronize do
|
|
74
|
+
if @apt_update_state[ host ]
|
|
75
|
+
false
|
|
76
|
+
else
|
|
77
|
+
@apt_update_state[ host ] = true
|
|
78
|
+
true
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
end
|