syncwrap 1.5.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/syncwrap/hashdot.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2011-2013 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/common'
|
18
|
-
require 'syncwrap/distro'
|
19
|
-
|
20
|
-
# Provisions the {Hashdot}[http://hashdot.sourceforge.net/] JVM/script
|
21
|
-
# launcher by building it with gcc on the target host.
|
22
|
-
module SyncWrap::Hashdot
|
23
|
-
include SyncWrap::Common
|
24
|
-
include SyncWrap::Distro
|
25
|
-
|
26
|
-
# Hashdot version (default: 1.4.0)
|
27
|
-
attr_accessor :hashdot_version
|
28
|
-
|
29
|
-
def initialize
|
30
|
-
super
|
31
|
-
|
32
|
-
@hashdot_version = '1.4.0'
|
33
|
-
end
|
34
|
-
|
35
|
-
def hashdot_install_system_deps
|
36
|
-
dist_install( %w[ make gcc apr apr-devel ] )
|
37
|
-
end
|
38
|
-
|
39
|
-
# Install hashdot if the binary is not found. If the binary is found
|
40
|
-
# then still attempt to update the profile config files.
|
41
|
-
def hashdot_install
|
42
|
-
if !exist?( "#{common_prefix}/bin/hashdot" )
|
43
|
-
hashdot_install!
|
44
|
-
else
|
45
|
-
# Just update config as needed.
|
46
|
-
rput( 'src/hashdot/profiles/',
|
47
|
-
"#{common_prefix}/lib/hashdot/profiles/",
|
48
|
-
:excludes => :dev, :user => 'root' )
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def hashdot_install!
|
53
|
-
hashdot_install_system_deps
|
54
|
-
|
55
|
-
url = ( "http://downloads.sourceforge.net/project/hashdot/" +
|
56
|
-
"hashdot/#{hashdot_version}/hashdot-#{hashdot_version}-src.tar.gz" )
|
57
|
-
src_root = '/tmp/src'
|
58
|
-
hd_src = "#{src_root}/hashdot-#{hashdot_version}"
|
59
|
-
|
60
|
-
run <<-SH
|
61
|
-
mkdir -p #{src_root}
|
62
|
-
rm -rf #{hd_src}
|
63
|
-
curl -sSL #{url} | tar -C #{src_root} -zxf -
|
64
|
-
SH
|
65
|
-
rput( 'src/hashdot/', "#{hd_src}/", :excludes => :dev )
|
66
|
-
run "cd #{hd_src} && make"
|
67
|
-
sudo "cd #{hd_src} && make install"
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
data/lib/syncwrap/iyyov.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2011-2013 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/user_run'
|
18
|
-
require 'syncwrap/distro'
|
19
|
-
require 'syncwrap/jruby'
|
20
|
-
|
21
|
-
# Provisions the {Iyyov}[http://rubydoc.info/gems/iyyov/] job
|
22
|
-
# scheduler and process monitor by jruby_install_gem.
|
23
|
-
module SyncWrap::Iyyov
|
24
|
-
include SyncWrap::UserRun
|
25
|
-
include SyncWrap::Distro
|
26
|
-
include SyncWrap::JRuby
|
27
|
-
|
28
|
-
attr_accessor :iyyov_version
|
29
|
-
|
30
|
-
def initialize
|
31
|
-
super
|
32
|
-
|
33
|
-
@iyyov_version = '1.1.4'
|
34
|
-
end
|
35
|
-
|
36
|
-
# Install then (re-)start Iyyov if needed, yield to block if given
|
37
|
-
# for daemon gem or other setup, then finally update remote
|
38
|
-
# (user_run) var/iyyov/jobs.rb; which will trigger any necessary
|
39
|
-
# restarts.
|
40
|
-
# === Options
|
41
|
-
# :install:: If true, run iyyov_install first and make sure iyyov is
|
42
|
-
# running (default: false)
|
43
|
-
def iyyov_install_jobs( opts = {} )
|
44
|
-
user_run_dir_setup
|
45
|
-
|
46
|
-
restart = opts[ :install ] && iyyov_install
|
47
|
-
if restart
|
48
|
-
iyyov_restart
|
49
|
-
sleep 15
|
50
|
-
elsif opts[ :install ] && !exist?( "#{iyyov_run_dir}/iyyov.pid" )
|
51
|
-
iyyov_start
|
52
|
-
sleep 15
|
53
|
-
end
|
54
|
-
|
55
|
-
# Any Iyyov restart completes *before* job changes
|
56
|
-
|
57
|
-
# FIXME: Need a better solution to wait on Iyyov than an arbitrary
|
58
|
-
# sleep.
|
59
|
-
|
60
|
-
tfile = '/tmp/iyyov_jobs_deploy'
|
61
|
-
sudo <<-SH
|
62
|
-
rm -f #{tfile}
|
63
|
-
touch #{tfile}
|
64
|
-
SH
|
65
|
-
|
66
|
-
yield if block_given?
|
67
|
-
|
68
|
-
user_run_rput( 'var/iyyov/jobs.rb', iyyov_run_dir )
|
69
|
-
|
70
|
-
# Touch jobs.rb if not changed by above, so iyyov can check if
|
71
|
-
# daemons need restart.
|
72
|
-
sudo( <<-SH, :user => user_run )
|
73
|
-
if [ #{iyyov_run_dir}/jobs.rb -ot #{tfile} ]; then
|
74
|
-
touch #{iyyov_run_dir}/jobs.rb
|
75
|
-
echo "touch #{iyyov_run_dir}/jobs.rb"
|
76
|
-
fi
|
77
|
-
SH
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
# Deploy iyyov gem, init.d/iyyov and at least an empty
|
82
|
-
# jobs.rb. Returns true if iyyov was installed/upgraded and should
|
83
|
-
# be restarted.
|
84
|
-
def iyyov_install
|
85
|
-
iyyov_install_rundir
|
86
|
-
|
87
|
-
if iyyov_install_gem
|
88
|
-
iyyov_install_init!
|
89
|
-
true
|
90
|
-
else
|
91
|
-
false
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
def iyyov_run_dir
|
97
|
-
"#{user_run_dir}/iyyov"
|
98
|
-
end
|
99
|
-
|
100
|
-
# Create iyyov rundir and make sure there is at minimum an empty
|
101
|
-
# jobs file. Avoid touching it if already present
|
102
|
-
def iyyov_install_rundir
|
103
|
-
sudo( <<-"SH", :user => user_run )
|
104
|
-
mkdir -p #{iyyov_run_dir}
|
105
|
-
if [ ! -e #{iyyov_run_dir}/jobs.rb ]; then
|
106
|
-
touch #{iyyov_run_dir}/jobs.rb
|
107
|
-
fi
|
108
|
-
SH
|
109
|
-
user_run_chown( '-R', iyyov_run_dir )
|
110
|
-
end
|
111
|
-
|
112
|
-
# Ensure install of same gem version as init.d/iyyov script
|
113
|
-
# Return true if installed
|
114
|
-
def iyyov_install_gem
|
115
|
-
jruby_install_gem( 'iyyov', :version => "=#{iyyov_version}",
|
116
|
-
:check => true )
|
117
|
-
end
|
118
|
-
|
119
|
-
# Install iyyov daemon init.d script and add to init daemons
|
120
|
-
def iyyov_install_init!
|
121
|
-
rput( 'etc/init.d/iyyov', :user => 'root' )
|
122
|
-
|
123
|
-
# Add to init.d
|
124
|
-
dist_install_init_service( 'iyyov' )
|
125
|
-
end
|
126
|
-
|
127
|
-
def iyyov_start
|
128
|
-
dist_service( 'iyyov', 'start' )
|
129
|
-
end
|
130
|
-
|
131
|
-
def iyyov_stop
|
132
|
-
dist_service( 'iyyov', 'stop' )
|
133
|
-
end
|
134
|
-
|
135
|
-
def iyyov_restart
|
136
|
-
dist_service( 'iyyov', 'restart' )
|
137
|
-
end
|
138
|
-
|
139
|
-
end
|
data/lib/syncwrap/java.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2011-2013 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/common'
|
18
|
-
|
19
|
-
# Provisions a JDK via an HTTP accessable binary repository of your
|
20
|
-
# making. Sun/Oracle JDK usage terms generally preclude sharing a
|
21
|
-
# binary repository for these.
|
22
|
-
module SyncWrap::Java
|
23
|
-
include SyncWrap::Common
|
24
|
-
|
25
|
-
# HTTP URL to repo base directory. Note that the default
|
26
|
-
# (http://localhost/repo) is unlikely to work here.
|
27
|
-
attr_accessor :java_repo_base_url
|
28
|
-
|
29
|
-
# The name of the JDK, which is used for download via
|
30
|
-
# java_repo_base_url/<name>.tar.gz and the expected top level
|
31
|
-
# directory when unpackaged.
|
32
|
-
attr_accessor :java_jdk_name
|
33
|
-
|
34
|
-
def initialize
|
35
|
-
super
|
36
|
-
|
37
|
-
@java_repo_base_url = 'http://localhost/repo'
|
38
|
-
@java_jdk_name = 'jdk-ora-1.7.0_07-x64'
|
39
|
-
end
|
40
|
-
|
41
|
-
def java_jdk_url
|
42
|
-
File.join( @java_repo_base_url, @java_jdk_name + '.tar.gz' )
|
43
|
-
end
|
44
|
-
|
45
|
-
def java_install
|
46
|
-
java_install! unless exist?( "#{common_prefix}/lib/#{java_jdk_name}" )
|
47
|
-
end
|
48
|
-
|
49
|
-
def java_install!
|
50
|
-
bins = %w[ java jmap jstack jstat jps jinfo jhat javac ].
|
51
|
-
map { |b| "../lib/java/bin/#{b}" }.
|
52
|
-
join( ' ' )
|
53
|
-
|
54
|
-
sudo <<-SH
|
55
|
-
curl -sSL #{java_jdk_url} | tar -C #{common_prefix}/lib -zxf -
|
56
|
-
cd #{common_prefix}/lib && ln -sfn #{java_jdk_name} java
|
57
|
-
cd #{common_prefix}/bin && ln -sfn #{bins} .
|
58
|
-
SH
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
data/lib/syncwrap/jruby.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2011-2013 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/common'
|
18
|
-
|
19
|
-
# Provisions JRuby by direct download from public S3 repo. Includes
|
20
|
-
# utility methods for checking and installing JRuby gems.
|
21
|
-
module SyncWrap::JRuby
|
22
|
-
include SyncWrap::Common
|
23
|
-
|
24
|
-
# JRuby version to install (default: 1.6.8)
|
25
|
-
attr_accessor :jruby_version
|
26
|
-
|
27
|
-
# The name of the gem command to be installed/used (default: jgem)
|
28
|
-
attr_accessor :jruby_gem_command
|
29
|
-
|
30
|
-
# Default gem install arguments (default: --no-rdoc, --no-ri)
|
31
|
-
attr_accessor :jruby_gem_install_args
|
32
|
-
|
33
|
-
def initialize
|
34
|
-
super
|
35
|
-
|
36
|
-
@jruby_version = '1.6.8'
|
37
|
-
@jruby_gem_command = 'jgem'
|
38
|
-
@jruby_gem_install_args = %w[ --no-rdoc --no-ri ]
|
39
|
-
end
|
40
|
-
|
41
|
-
def jruby_gemrc_path
|
42
|
-
"#{common_prefix}/lib/jruby/jruby-#{jruby_version}/etc"
|
43
|
-
end
|
44
|
-
|
45
|
-
# Install jruby if the jruby_version is not already present.
|
46
|
-
def jruby_install
|
47
|
-
unless exist?( "#{common_prefix}/lib/jruby/jruby-#{jruby_version}" )
|
48
|
-
jruby_install!
|
49
|
-
end
|
50
|
-
jruby_install_gemrc
|
51
|
-
end
|
52
|
-
|
53
|
-
# Install gemrc file to jruby_gemrc_path
|
54
|
-
def jruby_install_gemrc
|
55
|
-
sudo "mkdir -p #{jruby_gemrc_path}"
|
56
|
-
rput( 'etc/gemrc', jruby_gemrc_path, :user => 'root' )
|
57
|
-
end
|
58
|
-
|
59
|
-
# Install jruby, including usr/local/bin local contents
|
60
|
-
def jruby_install!
|
61
|
-
url = ( "http://jruby.org.s3.amazonaws.com/downloads/#{jruby_version}/" +
|
62
|
-
"jruby-bin-#{jruby_version}.tar.gz" )
|
63
|
-
|
64
|
-
root = "#{common_prefix}/lib/jruby"
|
65
|
-
|
66
|
-
sudo <<-SH
|
67
|
-
mkdir -p #{root}
|
68
|
-
mkdir -p #{root}/gems
|
69
|
-
curl -sSL #{url} | tar -C #{root} -zxf -
|
70
|
-
cd #{root} && ln -sfn jruby-#{jruby_version} jruby
|
71
|
-
cd #{common_prefix}/bin && ln -sf ../lib/jruby/jruby/bin/jirb .
|
72
|
-
SH
|
73
|
-
|
74
|
-
rput( 'usr/local/bin/', :excludes => :dev, :user => 'root' )
|
75
|
-
end
|
76
|
-
|
77
|
-
# Return true if gem is already installed.
|
78
|
-
# ==== Options
|
79
|
-
# :version:: Version specifier array, like in spec. files
|
80
|
-
# (default: none, i.e. latest)
|
81
|
-
# :user:: If true, perform a --user-install as current user, else
|
82
|
-
# system install with sudo (default: false )
|
83
|
-
def jruby_check_gem( gems, opts = {} )
|
84
|
-
query = [ jruby_gem_command, 'query', '-i',
|
85
|
-
jruby_gem_version_flags( opts[ :version ] ),
|
86
|
-
'-n', gems, '>/dev/null' ].flatten.compact
|
87
|
-
|
88
|
-
status = exec_conditional do
|
89
|
-
send( opts[ :user ] ? :run : :sudo, query )
|
90
|
-
end
|
91
|
-
( status == 0 )
|
92
|
-
end
|
93
|
-
|
94
|
-
# Install the specified gem(s)
|
95
|
-
# ==== Options
|
96
|
-
# :version:: Version specifier array, like in spec. files
|
97
|
-
# (default: none, i.e. latest)
|
98
|
-
# :user:: If true, perform a --user-install as current user, else
|
99
|
-
# system install with sudo (default: false )
|
100
|
-
def jruby_install_gem( gems, opts = {} )
|
101
|
-
if opts[ :check ] && jruby_check_gem( gems, opts )
|
102
|
-
false
|
103
|
-
else
|
104
|
-
cmd = [ jruby_gem_command, 'install',
|
105
|
-
jruby_gem_install_args,
|
106
|
-
( '--user-install' if opts[ :user ] ),
|
107
|
-
jruby_gem_version_flags( opts[ :version ] ),
|
108
|
-
gems ].flatten.compact
|
109
|
-
send( opts[ :user ] ? :run : :sudo, cmd )
|
110
|
-
true
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def jruby_gem_version_flags( reqs )
|
115
|
-
Array( reqs ).flatten.compact.map { |req| "-v'#{req}'" }
|
116
|
-
end
|
117
|
-
|
118
|
-
end
|
data/lib/syncwrap/postgresql.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2011-2013 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/distro'
|
18
|
-
require 'syncwrap/ubuntu'
|
19
|
-
require 'syncwrap/rhel'
|
20
|
-
|
21
|
-
# Provisions for install and configuration of PostgreSQL
|
22
|
-
module SyncWrap::PostgreSQL
|
23
|
-
include SyncWrap::Distro
|
24
|
-
|
25
|
-
# Location of postgresql data dir (databases + config in default
|
26
|
-
# case)
|
27
|
-
attr_accessor :pg_data_dir
|
28
|
-
|
29
|
-
# The stock distribution default data_dir. Difference with
|
30
|
-
# pg_data_dir triggers additional install steps.
|
31
|
-
attr_accessor :pg_default_data_dir
|
32
|
-
|
33
|
-
# Local directory for configuration files (different by
|
34
|
-
# distribution)
|
35
|
-
attr_accessor :pg_deploy_config
|
36
|
-
|
37
|
-
def initialize
|
38
|
-
super
|
39
|
-
@pg_data_dir = '/pg/data'
|
40
|
-
end
|
41
|
-
|
42
|
-
def pg_config_dir
|
43
|
-
@pg_data_dir
|
44
|
-
end
|
45
|
-
|
46
|
-
def pg_install
|
47
|
-
dist_install 'postgresql'
|
48
|
-
end
|
49
|
-
|
50
|
-
# Update PostgreSQL config files
|
51
|
-
def pg_configure
|
52
|
-
rput( "#{pg_deploy_config}/", pg_config_dir, :user => 'postgres' )
|
53
|
-
sudo( "chmod 700 #{pg_data_dir}" ) if pg_config_dir == pg_data_dir
|
54
|
-
end
|
55
|
-
|
56
|
-
def pg_start
|
57
|
-
dist_service( 'postgresql', 'start' )
|
58
|
-
end
|
59
|
-
|
60
|
-
def pg_stop
|
61
|
-
dist_service( 'postgresql', 'stop' )
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.included( base )
|
65
|
-
if base.include?( SyncWrap::RHEL )
|
66
|
-
base.send( :include, SyncWrap::PostgreSQL::RHEL )
|
67
|
-
elsif base.include?( SyncWrap::Ubuntu )
|
68
|
-
base.send( :include, SyncWrap::PostgreSQL::Ubuntu )
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
module RHEL
|
73
|
-
|
74
|
-
def initialize
|
75
|
-
super
|
76
|
-
#Per Amazon Linux 2012 3.3
|
77
|
-
@pg_default_data_dir = '/var/lib/pgsql9/data'
|
78
|
-
@pg_deploy_config = 'postgresql/rhel'
|
79
|
-
end
|
80
|
-
|
81
|
-
def pg_install
|
82
|
-
super
|
83
|
-
unless @pg_data_dir == @pg_default_data_dir
|
84
|
-
# (Per Amazon Linux)
|
85
|
-
# Install PGDATA var override for init.d/postgresql
|
86
|
-
rput( 'etc/sysconfig/pgsql/postgresql', :user => 'root' )
|
87
|
-
sudo <<-SH
|
88
|
-
mkdir -p #{pg_data_dir}
|
89
|
-
chown postgres:postgres #{pg_data_dir}
|
90
|
-
chmod 700 #{pg_data_dir}
|
91
|
-
SH
|
92
|
-
end
|
93
|
-
dist_service( 'postgresql', 'initdb' )
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
97
|
-
|
98
|
-
module Ubuntu
|
99
|
-
|
100
|
-
def initialize
|
101
|
-
super
|
102
|
-
@pg_default_data_dir = '/var/lib/postgresql/9.1/main'
|
103
|
-
@pg_deploy_config = 'postgresql/ubuntu'
|
104
|
-
end
|
105
|
-
|
106
|
-
def pg_install
|
107
|
-
super
|
108
|
-
pg_stop #Ubuntu does a start
|
109
|
-
pg_adjust_sysctl
|
110
|
-
pg_relocate unless @pg_data_dir == @pg_default_data_dir
|
111
|
-
end
|
112
|
-
|
113
|
-
def pg_config_dir
|
114
|
-
"/etc/postgresql/9.1/main"
|
115
|
-
end
|
116
|
-
|
117
|
-
def pg_adjust_sysctl
|
118
|
-
rput( 'etc/sysctl.d/61-postgresql-shm.conf', :user => 'root' )
|
119
|
-
sudo "sysctl -p /etc/sysctl.d/61-postgresql-shm.conf"
|
120
|
-
end
|
121
|
-
|
122
|
-
# Move the data dir into its final location, since on Ubuntu the
|
123
|
-
# package install does the initdb step
|
124
|
-
def pg_relocate
|
125
|
-
sudo <<-SH
|
126
|
-
mkdir -p #{pg_data_dir}
|
127
|
-
chown postgres:postgres #{pg_data_dir}
|
128
|
-
chmod 700 #{pg_data_dir}
|
129
|
-
mv #{pg_default_data_dir}/* #{pg_data_dir}/
|
130
|
-
SH
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|