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.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/History.rdoc +19 -0
  3. data/Manifest.txt +82 -34
  4. data/README.rdoc +96 -48
  5. data/Rakefile +0 -65
  6. data/bin/syncwrap +27 -0
  7. data/examples/LAYOUT.rdoc +70 -0
  8. data/examples/Rakefile +16 -0
  9. data/examples/ec2.rb +44 -0
  10. data/examples/hello.rb +14 -0
  11. data/examples/hello_binding.rb +27 -0
  12. data/examples/jruby.rb +11 -0
  13. data/examples/private/aws.json +4 -0
  14. data/examples/rput.rb +24 -0
  15. data/examples/sync/home/bob/.ssh/authorized_keys +1 -0
  16. data/examples/sync/tmp/sample.erb +3 -0
  17. data/lib/syncwrap/amazon_ec2.rb +236 -0
  18. data/lib/syncwrap/amazon_ws.rb +308 -0
  19. data/lib/syncwrap/base.rb +4 -2
  20. data/lib/syncwrap/cli.rb +328 -0
  21. data/lib/syncwrap/component.rb +443 -0
  22. data/lib/syncwrap/components/commercial_jdk.rb +76 -0
  23. data/lib/syncwrap/components/cruby_vm.rb +144 -0
  24. data/lib/syncwrap/components/etc_hosts.rb +44 -0
  25. data/lib/syncwrap/{geminabox.rb → components/geminabox.rb} +12 -17
  26. data/lib/syncwrap/components/hashdot.rb +97 -0
  27. data/lib/syncwrap/components/iyyov.rb +144 -0
  28. data/lib/syncwrap/components/iyyov_daemon.rb +125 -0
  29. data/lib/syncwrap/components/jruby_vm.rb +122 -0
  30. data/lib/syncwrap/components/mdraid.rb +204 -0
  31. data/lib/syncwrap/components/network.rb +99 -0
  32. data/lib/syncwrap/components/open_jdk.rb +70 -0
  33. data/lib/syncwrap/components/postgresql.rb +159 -0
  34. data/lib/syncwrap/components/qpid.rb +303 -0
  35. data/lib/syncwrap/components/rhel.rb +71 -0
  36. data/lib/syncwrap/components/run_user.rb +99 -0
  37. data/lib/syncwrap/components/ubuntu.rb +85 -0
  38. data/lib/syncwrap/components/users.rb +200 -0
  39. data/lib/syncwrap/context.rb +260 -0
  40. data/lib/syncwrap/distro.rb +53 -60
  41. data/lib/syncwrap/formatter.rb +149 -0
  42. data/lib/syncwrap/host.rb +134 -0
  43. data/lib/syncwrap/main.rb +62 -0
  44. data/lib/syncwrap/path_util.rb +55 -0
  45. data/lib/syncwrap/rsync.rb +227 -0
  46. data/lib/syncwrap/ruby_support.rb +110 -0
  47. data/lib/syncwrap/shell.rb +207 -0
  48. data/lib/syncwrap.rb +367 -1
  49. data/{etc → sync/etc}/gemrc +1 -3
  50. data/sync/etc/hosts.erb +8 -0
  51. data/{etc/init.d/iyyov → sync/etc/init.d/iyyov.erb} +35 -7
  52. data/sync/etc/sysconfig/pgsql/postgresql.erb +2 -0
  53. data/sync/src/hashdot/Makefile.erb +98 -0
  54. data/sync/src/hashdot/profiles/default.hdp.erb +25 -0
  55. data/sync/src/hashdot/profiles/jruby-common.hdp +28 -0
  56. data/sync/src/hashdot/profiles/jruby-shortlived.hdp +9 -0
  57. data/sync/src/hashdot/profiles/jruby.hdp.erb +13 -0
  58. data/sync/src/hashdot/profiles/shortlived.hdp +6 -0
  59. data/sync/var/iyyov/default/config.rb +1 -0
  60. data/sync/var/iyyov/default/daemon.rb.erb +15 -0
  61. data/sync/var/iyyov/jobs.rb.erb +4 -0
  62. data/test/muddled_sync.rb +13 -0
  63. data/test/setup.rb +39 -0
  64. data/test/sync/d1/bar +1 -0
  65. data/test/sync/d1/foo.erb +1 -0
  66. data/test/sync/d3/d2/bar +1 -0
  67. data/test/sync/d3/d2/foo.erb +1 -0
  68. data/test/test_components.rb +108 -0
  69. data/test/test_context.rb +107 -0
  70. data/test/test_context_rput.rb +289 -0
  71. data/test/test_rsync.rb +138 -0
  72. data/test/test_shell.rb +233 -0
  73. data/test/test_space.rb +218 -0
  74. data/test/test_space_main.rb +40 -0
  75. data/test/zfile +1 -0
  76. metadata +204 -71
  77. data/etc/sysconfig/pgsql/postgresql +0 -2
  78. data/lib/syncwrap/aws.rb +0 -448
  79. data/lib/syncwrap/common.rb +0 -161
  80. data/lib/syncwrap/ec2.rb +0 -59
  81. data/lib/syncwrap/hashdot.rb +0 -70
  82. data/lib/syncwrap/iyyov.rb +0 -139
  83. data/lib/syncwrap/java.rb +0 -61
  84. data/lib/syncwrap/jruby.rb +0 -118
  85. data/lib/syncwrap/postgresql.rb +0 -135
  86. data/lib/syncwrap/qpid.rb +0 -251
  87. data/lib/syncwrap/remote_task.rb +0 -199
  88. data/lib/syncwrap/rhel.rb +0 -67
  89. data/lib/syncwrap/ubuntu.rb +0 -78
  90. data/lib/syncwrap/user_run.rb +0 -102
  91. data/test/test_syncwrap.rb +0 -202
  92. data/var/iyyov/jobs.rb +0 -11
  93. /data/{etc → sync/etc}/corosync/corosync.conf +0 -0
  94. /data/{etc → sync/etc}/corosync/uidgid.d/qpid +0 -0
  95. /data/{etc → sync/etc}/init.d/qpidd +0 -0
  96. /data/{etc → sync/etc}/sysctl.d/61-postgresql-shm.conf +0 -0
  97. /data/{usr/local → sync/jruby}/bin/jgem +0 -0
  98. /data/{postgresql → sync/postgresql}/rhel/pg_hba.conf +0 -0
  99. /data/{postgresql → sync/postgresql}/rhel/pg_ident.conf +0 -0
  100. /data/{postgresql → sync/postgresql}/rhel/postgresql.conf +0 -0
  101. /data/{postgresql → sync/postgresql}/ubuntu/environment +0 -0
  102. /data/{postgresql → sync/postgresql}/ubuntu/pg_ctl.conf +0 -0
  103. /data/{postgresql → sync/postgresql}/ubuntu/pg_hba.conf +0 -0
  104. /data/{postgresql → sync/postgresql}/ubuntu/pg_ident.conf +0 -0
  105. /data/{postgresql → sync/postgresql}/ubuntu/postgresql.conf +0 -0
  106. /data/{postgresql → sync/postgresql}/ubuntu/start.conf +0 -0
  107. /data/{usr → sync/usr}/local/etc/qpidd.conf +0 -0
data/lib/syncwrap/qpid.rb DELETED
@@ -1,251 +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
- # Qpid AMQP broker provisioning. Currently this is RHEL/AmazonLinux
21
- # centric.
22
- module SyncWrap::Qpid
23
- include SyncWrap::Common
24
- include SyncWrap::Distro
25
-
26
- attr_accessor :qpid_src_root
27
-
28
- attr_accessor :qpid_version
29
- attr_accessor :qpid_repo
30
- attr_accessor :qpid_distro
31
-
32
- attr_accessor :corosync_version
33
- attr_accessor :corosync_repo
34
-
35
- def initialize
36
- super
37
-
38
- @qpid_src_root = '/tmp/src'
39
-
40
- @qpid_version = '0.18'
41
- @qpid_repo = 'http://apache.osuosl.org/qpid'
42
- @qpid_distro = 'amzn1'
43
-
44
- @corosync_version = '1.4.4'
45
- @corosync_repo = 'https://github.com/downloads/corosync/corosync'
46
- end
47
-
48
- def qpid_install
49
- unless exist?( "/usr/local/sbin/qpidd" )
50
- qpid_install!
51
- qpid_install_init!
52
- end
53
- qpid_tools_install
54
- rput( 'usr/local/etc/qpidd.conf', :user => 'root' )
55
- end
56
-
57
- def qpid_install_init!
58
- unless exec_conditional { run "id qpidd >/dev/null" } == 0
59
- sudo <<-SH
60
- useradd -r qpidd
61
- mkdir -p /var/local/qpidd
62
- chown qpidd:qpidd /var/local/qpidd
63
- SH
64
- end
65
-
66
- rput( 'etc/init.d/qpidd', :user => 'root' )
67
-
68
- # Add to init.d
69
- dist_install_init_service( 'qpidd' )
70
- end
71
-
72
- def qpid_tools_install
73
- unless exist?( "/usr/bin/qpid-config" )
74
- qpid_tools_install!
75
- end
76
- end
77
-
78
- def qpid_install!
79
- corosync_install!( :devel => true )
80
- qpid_build
81
- end
82
-
83
- def qpid_tools_install!
84
- dist_install( 'python-setuptools' )
85
- qpid_src = "#{qpid_src_root}/qpid-#{qpid_version}"
86
-
87
- run <<-SH
88
- mkdir -p #{qpid_src_root}
89
- rm -rf #{qpid_src}
90
- cd #{qpid_src_root}
91
- curl -sSL #{qpid_tools_tarball} | tar -zxf -
92
- SH
93
-
94
- sudo <<-SH
95
- cd #{qpid_src}
96
- easy_install ./python ./tools ./extras/qmf
97
- SH
98
- end
99
-
100
- def qpid_build
101
- qpid_install_build_deps
102
- qpid_install_deps
103
-
104
- qpid_src = "#{qpid_src_root}/qpidc-#{qpid_version}"
105
-
106
- run <<-SH
107
- mkdir -p #{qpid_src_root}
108
- rm -rf #{qpid_src}
109
- cd #{qpid_src_root}
110
- curl -sSL #{qpid_src_tarball} | tar -zxf -
111
- cd #{qpid_src}
112
- ./configure > /dev/null
113
- make > /dev/null
114
- SH
115
-
116
- sudo <<-SH
117
- cd #{qpid_src}
118
- make install > /dev/null
119
- SH
120
-
121
- run <<-SH
122
- cd #{qpid_src}
123
- make check > /dev/null
124
- SH
125
-
126
- sudo <<-SH
127
- cd /usr/local
128
- rm -f /tmp/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz
129
- tar -zc \
130
- --exclude games --exclude lib64/perl5 --exclude src \
131
- --exclude share/man --exclude share/perl5 --exclude share/info \
132
- --exclude share/applications \
133
- -f /tmp/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz .
134
- SH
135
- end
136
-
137
- def qpid_src_tarball
138
- "#{qpid_repo}/#{qpid_version}/qpid-cpp-#{qpid_version}.tar.gz"
139
- end
140
-
141
- def qpid_tools_tarball
142
- "#{qpid_repo}/#{qpid_version}/qpid-#{qpid_version}.tar.gz"
143
- end
144
-
145
- def qpid_install_build_deps
146
- dist_install( %w[ gcc gcc-c++ make autogen autoconf
147
- help2man libtool pkgconfig rpm-build ] )
148
- end
149
-
150
- def qpid_install_deps
151
- dist_install( %w[ nss-devel boost-devel libuuid-devel swig
152
- ruby-devel python-devel cyrus-sasl-devel ] )
153
- end
154
-
155
- def corosync_install( opts = {} )
156
- unless exist?( "/usr/sbin/corosync" )
157
- corosync_install!( opts )
158
- end
159
- end
160
-
161
- def corosync_install!( opts = {} )
162
- corosync_build
163
- dist_install( "#{corosync_src}/x86_64/*.rpm", :succeed => true )
164
- end
165
-
166
- def corosync_build
167
- qpid_install_build_deps
168
- corosync_install_build_deps
169
-
170
- run <<-SH
171
- mkdir -p #{qpid_src_root}
172
- rm -rf #{corosync_src}
173
- cd #{qpid_src_root}
174
- curl -sSL #{corosync_repo}/corosync-#{corosync_version}.tar.gz | tar -zxf -
175
- cd #{corosync_src}
176
- ./autogen.sh
177
- ./configure > /dev/null
178
- make rpm > /dev/null
179
- SH
180
-
181
- end
182
-
183
- def corosync_packages( include_devel = false )
184
- packs = [ "corosync-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm",
185
- "corosynclib-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm" ]
186
- packs << "corosynclib-devel-#{corosync_version}-1.#{qpid_distro}.x86_64.rpm" if include_devel
187
- packs
188
- end
189
-
190
- def corosync_install_build_deps
191
- dist_install( %w[ nss-devel libibverbs-devel librdmacm-devel ] )
192
- end
193
-
194
- def corosync_src
195
- "#{qpid_src_root}/corosync-#{corosync_version}"
196
- end
197
-
198
- # Simplify qpid install by using pre-built binaries (for example,
199
- # archived from the build steps above.)
200
- module BinRepo
201
- include SyncWrap::Qpid
202
-
203
- attr_accessor :qpid_prebuild_repo
204
-
205
- def initialize
206
- super
207
-
208
- @qpid_prebuild_repo = nil
209
- end
210
-
211
- def qpid_install
212
- corosync_install
213
- super
214
- end
215
-
216
- def qpid_install!
217
- raise "qpid_prebuild_repo required, but not set" unless qpid_prebuild_repo
218
-
219
- dist_install( %w[ boost cyrus-sasl ] )
220
-
221
- sudo <<-SH
222
- cd /usr/local
223
- curl -sS #{qpid_prebuild_repo}/qpidc-#{qpid_version}-1-#{qpid_distro}-x64.tar.gz | tar -zxf -
224
- SH
225
- end
226
-
227
- def corosync_install!( opts = {} )
228
- raise "qpid_prebuild_repo required, but not set" unless qpid_prebuild_repo
229
- packs = corosync_packages
230
- curls = packs.map do |p|
231
- "curl -sS -O #{qpid_prebuild_repo}/#{p}"
232
- end
233
-
234
- sudo <<-SH
235
- rm -rf /tmp/rpm-drop
236
- mkdir -p /tmp/rpm-drop
237
- cd /tmp/rpm-drop
238
- #{curls.join("\n")}
239
- SH
240
- dist_install( "/tmp/rpm-drop/*.rpm", :succeed => true )
241
- end
242
-
243
- # Where uploaded qpid-python-tools-M.N.tar.gz contains the
244
- # ./python ./tools ./extras/qmf packages for easy_install.
245
- def qpid_tools_tarball
246
- "#{qpid_prebuild_repo}/qpid-python-tools-#{qpid_version}.tar.gz"
247
- end
248
-
249
- end
250
-
251
- end
@@ -1,199 +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 'rake/remote_task'
18
-
19
- require 'syncwrap/base'
20
- require 'syncwrap/common'
21
-
22
- # Implements common remoting methods in terms of rake/remote_task (and
23
- # thus Vlad compatible)
24
- module SyncWrap::RemoteTask
25
- include SyncWrap::Common
26
- include Rake::DSL
27
-
28
- # Array of zero to many host_names (typically short) that were
29
- # extracted from the HOSTS environment variable if set.
30
- attr_reader :hosts
31
-
32
- # A common domain name for all hosts, used to make host_long_name if
33
- # specified (default: nil)
34
- attr_accessor :common_domain
35
-
36
- def initialize
37
- @common_domain = nil
38
- interpret_hosts_var
39
- super
40
-
41
- # Defaults:
42
- set( :sudo_flags, %w[ -H ] )
43
- set( :rsync_flags, %w[ -rlpcb -ii ] )
44
-
45
- load_hosts_from_aws_instances if defined? aws_instances
46
- end
47
-
48
- # Implements SyncWrap::Common#run
49
- def run( *args )
50
- opts = args.last.is_a?( Hash ) && args.pop || {}
51
-
52
- exit_multi = opts[ :error ].nil? || opts[ :error ] == :exit
53
-
54
- args = cleanup_arg_lines( args, exit_multi )
55
-
56
- remote_task_current.run( *args )
57
- end
58
-
59
- # Implements SyncWrap::Common#sudo
60
- def sudo( *args )
61
- opts = args.last.is_a?( Hash ) && args.pop || {}
62
-
63
- flags = opts[ :flags ] || []
64
- if opts[ :user ]
65
- flags += [ '-u', opts[ :user ] ]
66
- end
67
-
68
- unless opts[ :shell ] == false
69
- exit_multi = opts[ :error ].nil? || opts[ :error ] == :exit
70
- cmd = cleanup_arg_lines( args, exit_multi )
71
- cmd = shell_escape_cmd( cmd.join( ' ' ) )
72
- cmd = "sh -c \"#{cmd}\""
73
- else
74
- cmd = cleanup_arg_lines( args, false )
75
- end
76
-
77
- remote_task_current.sudo( [ flags, cmd ] )
78
- end
79
-
80
- # Implements SyncWrap::Common#rsync
81
- def rsync( *args )
82
- remote_task_current.rsync( *args )
83
- end
84
-
85
- # Return the target host name of the currently executing RemoteTask.
86
- # Raises a StandardError if executed out of that context.
87
- def target_host
88
- remote_task_current.target_host
89
- end
90
-
91
- # Return true if the current target_host or specified host is part
92
- # of the specified role.
93
- def host_in_role?( role, host = target_host )
94
- role_hosts = Rake::RemoteTask.roles[ role ]
95
- role_hosts && !!( role_hosts[ host ] )
96
- end
97
-
98
- # Implements Common#exec_conditional
99
- def exec_conditional
100
- yield
101
- 0
102
- rescue Rake::CommandFailedError => e
103
- e.status
104
- end
105
-
106
- # Remove extra whitespace from multi-line and single arguments
107
- def cleanup_arg_lines( args, exit_error_on_multi )
108
- args.flatten.compact.map do |arg|
109
- alines = arg.split( $/ )
110
- if alines.length > 1 && exit_error_on_multi
111
- alines.unshift( "set -e" )
112
- end
113
- alines.map { |f| f.strip }.join( $/ )
114
- end
115
- end
116
-
117
- def shell_escape_cmd( cmd )
118
- cmd.gsub( /["$`\\]/ ) { |c| '\\' + c }
119
- end
120
-
121
- def remote_task( name, *args, &block )
122
- Rake::RemoteTask.remote_task( name, *args, &block )
123
- end
124
-
125
- def set( *args )
126
- Rake::RemoteTask.set( *args )
127
- end
128
-
129
- def interpret_hosts_var
130
- hvar, ENV[ 'HOSTS' ] = ENV[ 'HOSTS' ], nil
131
- @hosts = (hvar || '').strip.split( /\s+/ )
132
- @host_pattern = if @hosts.empty?
133
- // #match all if none specified.
134
- else
135
- Regexp.new( '^((' + @hosts.join( ')|(' ) + '))$' )
136
- end
137
- end
138
-
139
- # Forward to Rake::RemoteTask.host using the host_long_name, but
140
- # only if the specified host_name matches any host_pattern. The :all
141
- # role is automatically included for all hosts. Note this need not
142
- # be manually provided int the Rakefile if aws_instances is provided
143
- # instead.
144
- def host( host_name, *roles )
145
- if host_name =~ @host_pattern
146
- Rake::RemoteTask.host( host_long_name( host_name ), :all, *roles )
147
- end
148
- end
149
-
150
- # Define a RemoteTask host from an inst hash as defined by the AWS
151
- # module. Override to change how instances are mapped to RemoteTask, host By
152
- # default, using host_long_name( inst[:name] )
153
- def host_from_instance( inst )
154
- host( inst[:name], *inst[:roles] )
155
- end
156
-
157
- # Calls host_from_instance for all aws_instances.
158
- def load_hosts_from_aws_instances
159
- aws_instances.each do |inst|
160
- host_from_instance( inst )
161
- end
162
- end
163
-
164
- # Speculative override from AWS to automaticly set a host when added.
165
- # Will fail if used without AWS module as super receiver.
166
- def aws_instance_added( inst )
167
- super
168
- host_from_instance( inst )
169
- end
170
-
171
- # Forward to Rake::RemoteTask.role using the host_long_name, but only if
172
- # the specified host_name matches any host_pattern.
173
- def role( role_name, host_name = nil, args = {} )
174
- if host_name =~ @host_pattern
175
- Rake::RemoteTask.role( role_name, host_long_name( host_name ), args )
176
- end
177
- end
178
-
179
- def remote_task_current
180
- Thread.current[ :task ] or raise "Not running from a RemoteTask"
181
- end
182
-
183
- # Return a long name for the specified host_name (which may be
184
- # short). This implementation adds common_domain if
185
- # specified. Otherwise host_name is returned unmodified.
186
- def host_long_name( host_name )
187
- if common_domain
188
- "#{host_name}.#{common_domain}"
189
- else
190
- host_name
191
- end
192
- end
193
-
194
- # Return a short name for the specified host_name (which may be long).
195
- def host_short_name( host_name )
196
- ( host_name =~ /^([a-z0-9\-]+)/ ) && $1
197
- end
198
-
199
- end
data/lib/syncwrap/rhel.rb DELETED
@@ -1,67 +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
-
19
- # Customizations for RedHat Enterprise Linux and derivatives like
20
- # CentOS and Amazon Linux. Specific distros/versions may further
21
- # override these.
22
- module SyncWrap::RHEL
23
- include SyncWrap::Distro
24
-
25
- def initialize
26
- super
27
-
28
- packages_map.merge!( 'emacs' => 'emacs-nox',
29
- 'postgresql' => 'postgresql-server' )
30
- end
31
-
32
- # Generate command to install packages. The last argument is
33
- # interpreted as a options if it is a Hash.
34
- # === Options
35
- # :succeed:: Always succeed (useful for local rpms which might
36
- # already be installed.
37
- def dist_install_s( *args )
38
- if args.last.is_a?( Hash )
39
- args = args.dup
40
- opts = args.pop
41
- else
42
- opts = {}
43
- end
44
-
45
- args = dist_map_packages( args )
46
-
47
- if opts[ :succeed ]
48
- "yum install -q -y #{args.join ' '} || true"
49
- else
50
- "yum install -q -y #{args.join ' '}"
51
- end
52
- end
53
-
54
- def dist_uninstall_s( *args )
55
- args = dist_map_packages( args )
56
- "yum remove -q -y #{args.join ' '}"
57
- end
58
-
59
- def dist_install_init_service_s( name )
60
- "/sbin/chkconfig --add #{name}"
61
- end
62
-
63
- def dist_service_s( *args )
64
- "/sbin/service #{args.join ' '}"
65
- end
66
-
67
- end
@@ -1,78 +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 'thread'
19
-
20
- # Customizations for Ubuntu and possibly other Debian/apt packaged
21
- # derivatives. Specific distros/versions may further specialize.
22
- module SyncWrap::Ubuntu
23
- include SyncWrap::Distro
24
-
25
- def initialize
26
- @apt_update_state_lock = Mutex.new
27
- @apt_update_state = {}
28
-
29
- super
30
-
31
- packages_map.merge!( 'apr' => 'libapr1',
32
- 'apr-devel' => 'libapr1-dev' )
33
- end
34
-
35
- # Generate the apt-get command to install packages. The first time
36
- # this is applied to any given host, an "apt-get update" is issued
37
- # as well. The last argument is interpreted as a options if it is a
38
- # Hash.
39
- # === Options
40
- # :minimal:: Eqv to --no-install-recommends
41
- def dist_install_s( *args )
42
- args = args.dup
43
- if args.last.is_a?( Hash )
44
- opts = args.pop
45
- else
46
- opts = {}
47
- end
48
-
49
- commands = []
50
-
51
- @apt_update_state_lock.synchronize do
52
- unless @apt_update_state[ target_host ]
53
- commands << "apt-get -yq update"
54
- @apt_update_state[ target_host ] = true
55
- end
56
- end
57
-
58
- args = dist_map_packages( args )
59
- args.unshift "--no-install-recommends" if opts[ :minimal ]
60
- commands << "apt-get -yq install #{args.join ' '}"
61
-
62
- commands.join( "\n" )
63
- end
64
-
65
- def dist_uninstall_s( *args )
66
- args = dist_map_packages( args )
67
- "aptitude -yq purge #{args.join ' '}"
68
- end
69
-
70
- def dist_install_init_service_s( name )
71
- "/usr/sbin/update-rc.d #{name} defaults"
72
- end
73
-
74
- def dist_service_s( *args )
75
- "/usr/sbin/service #{args.join ' '}"
76
- end
77
-
78
- end
@@ -1,102 +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 for a (daemon) run user and var directory. Utilities for
20
- # working with the same.
21
- module SyncWrap::UserRun
22
- include SyncWrap::Common
23
-
24
- # A user for running deployed daemons, jobs (default: 'runr')
25
- attr_accessor :user_run
26
-
27
- # A group for running (default: 'runr')
28
- attr_accessor :user_run_group
29
-
30
- # Directory for persistent data, logs. (default: /var/local/runr)
31
- attr_accessor :user_run_dir
32
-
33
- def initialize
34
- super
35
-
36
- @user_run = 'runr'
37
- @user_run_group = 'runr'
38
-
39
- @user_run_dir = '/var/local/runr'
40
- end
41
-
42
- # Create and set owner/permission of run_dir, such that user_run may
43
- # create new directories there.
44
- def user_run_dir_setup
45
- user_create
46
- sudo <<-SH
47
- mkdir -p #{user_run_dir}
48
- chown #{user_run}:#{user_run_group} #{user_run_dir}
49
- chmod 775 #{user_run_dir}
50
- SH
51
- end
52
-
53
- # Create and set owner/permission of a named service directory under
54
- # user_run_dir.
55
- def user_run_service_dir_setup( sname, instance = nil )
56
- sdir = user_run_service_dir( sname, instance )
57
-
58
- sudo <<-SH
59
- mkdir -p #{sdir}
60
- chown #{user_run}:#{user_run_group} #{sdir}
61
- chmod 775 #{sdir}
62
- SH
63
- end
64
-
65
- def user_run_service_dir( sname, instance = nil )
66
- "#{user_run_dir}/" + [ sname, instance ].compact.join( '-' )
67
- end
68
-
69
- # As per SyncWrap::Common#rput with :user => user_run
70
- def user_run_rput( *args )
71
- opts = args.last.is_a?( Hash ) && args.pop || {}
72
- opts[ :user ] = user_run
73
- args.push( opts )
74
- rput( *args )
75
- end
76
-
77
- # Chown to user_run where args may be flags and files/directories.
78
- def user_run_chown( *args )
79
- flags, paths = args.partition { |a| a =~ /^-/ }
80
- sudo( 'chown', flags, "#{user_run}:#{user_run_group}", paths )
81
- end
82
-
83
- def user_exist?
84
- exec_conditional { run "id #{user_run} >/dev/null" } == 0
85
- end
86
-
87
- def user_create
88
- user_create! unless user_exist?
89
- end
90
-
91
- def user_create!
92
- if user_run_group == user_run
93
- sudo "useradd #{user_run}"
94
- else
95
- sudo <<-SH
96
- groupadd #{user_run_group}
97
- useradd -g #{user_run_group} #{user_run}
98
- SH
99
- end
100
- end
101
-
102
- end