capistrano-jdk-installer 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module JDKInstaller
3
- VERSION = "0.0.6"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /.vagrant
3
+ /known_hosts
4
+ /tmp
5
+ /vendor
@@ -0,0 +1,2 @@
1
+ load "deploy"
2
+ load "../config/deploy"
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec(:path => "../..")
@@ -0,0 +1,99 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant::Config.run do |config|
5
+ # All Vagrant configuration is done here. The most common configuration
6
+ # options are documented and commented below. For a complete reference,
7
+ # please see the online documentation at vagrantup.com.
8
+
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "centos6-64"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box"
15
+
16
+ # Boot with a GUI so you can see the screen. (Default is headless)
17
+ # config.vm.boot_mode = :gui
18
+
19
+ # Assign this VM to a host-only network IP, allowing you to access it
20
+ # via the IP. Host-only networks can talk to the host machine as well as
21
+ # any other machines on the same network, but cannot be accessed (through this
22
+ # network interface) by any external networks.
23
+ config.vm.network :hostonly, "192.168.33.10"
24
+
25
+ # Assign this VM to a bridged network, allowing you to connect directly to a
26
+ # network using the host's network device. This makes the VM appear as another
27
+ # physical device on your network.
28
+ # config.vm.network :bridged
29
+
30
+ # Forward a port from the guest to the host, which allows for outside
31
+ # computers to access the VM, whereas host only networking does not.
32
+ # config.vm.forward_port 80, 8080
33
+
34
+ # Share an additional folder to the guest VM. The first argument is
35
+ # an identifier, the second is the path on the guest to mount the
36
+ # folder, and the third is the path on the host to the actual folder.
37
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
38
+
39
+ # Enable provisioning with Puppet stand alone. Puppet manifests
40
+ # are contained in a directory path relative to this Vagrantfile.
41
+ # You will need to create the manifests directory and a manifest in
42
+ # the file precise-amd64.pp in the manifests_path directory.
43
+ #
44
+ # An example Puppet manifest to provision the message of the day:
45
+ #
46
+ # # group { "puppet":
47
+ # # ensure => "present",
48
+ # # }
49
+ # #
50
+ # # File { owner => 0, group => 0, mode => 0644 }
51
+ # #
52
+ # # file { '/etc/motd':
53
+ # # content => "Welcome to your Vagrant-built virtual machine!
54
+ # # Managed by Puppet.\n"
55
+ # # }
56
+ #
57
+ # config.vm.provision :puppet do |puppet|
58
+ # puppet.manifests_path = "manifests"
59
+ # puppet.manifest_file = "precise-amd64.pp"
60
+ # end
61
+
62
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
63
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
64
+ # some recipes and/or roles.
65
+ #
66
+ # config.vm.provision :chef_solo do |chef|
67
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
68
+ # chef.roles_path = "../my-recipes/roles"
69
+ # chef.data_bags_path = "../my-recipes/data_bags"
70
+ # chef.add_recipe "mysql"
71
+ # chef.add_role "web"
72
+ #
73
+ # # You may also specify custom JSON attributes:
74
+ # chef.json = { :mysql_password => "foo" }
75
+ # end
76
+
77
+ # Enable provisioning with chef server, specifying the chef server URL,
78
+ # and the path to the validation key (relative to this Vagrantfile).
79
+ #
80
+ # The Opscode Platform uses HTTPS. Substitute your organization for
81
+ # ORGNAME in the URL and validation key.
82
+ #
83
+ # If you have your own Chef Server, use the appropriate URL, which may be
84
+ # HTTP instead of HTTPS depending on your configuration. Also change the
85
+ # validation key to validation.pem.
86
+ #
87
+ # config.vm.provision :chef_client do |chef|
88
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
89
+ # chef.validation_key_path = "ORGNAME-validator.pem"
90
+ # end
91
+ #
92
+ # If you're using the Opscode platform, your validator client is
93
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
94
+ #
95
+ # IF you have your own Chef Server, the default validation client name is
96
+ # chef-validator, unless you changed the configuration.
97
+ #
98
+ # chef.validation_client_name = "ORGNAME-validator"
99
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/sh -e
2
+
3
+ bundle exec vagrant up
4
+ bundle exec cap test_all
5
+ bundle exec vagrant halt
6
+
7
+ # vim:set ft=sh :
@@ -0,0 +1,309 @@
1
+ set :application, "capistrano-jdk-installer"
2
+ set :repository, "."
3
+ set :deploy_to do
4
+ File.join("/home", user, application)
5
+ end
6
+ set :deploy_via, :copy
7
+ set :scm, :none
8
+ set :use_sudo, false
9
+ set :user, "vagrant"
10
+ set :password, "vagrant"
11
+ set :ssh_options, {:user_known_hosts_file => "/dev/null"}
12
+
13
+ ## java ##
14
+ set(:java_version_name, "7u15")
15
+ set(:java_oracle_username) { ENV["JAVA_ORACLE_USERNAME"] || abort("java_oracle_username was not set") }
16
+ set(:java_oracle_password) { ENV["JAVA_ORACLE_PASSWORD"] || abort("java_oracle_password was not set") }
17
+ set(:java_tools_path_local) { File.expand_path("tmp/java") }
18
+
19
+ role :web, "192.168.33.10"
20
+ role :app, "192.168.33.10"
21
+ role :db, "192.168.33.10", :primary => true
22
+
23
+ $LOAD_PATH.push(File.expand_path("../../lib", File.dirname(__FILE__)))
24
+ require "capistrano-jdk-installer"
25
+
26
+ def _invoke_command(cmdline, options={})
27
+ if options[:via] == :run_locally
28
+ run_locally(cmdline)
29
+ else
30
+ invoke_command(cmdline, options)
31
+ end
32
+ end
33
+
34
+ def assert_file_exists(file, options={})
35
+ begin
36
+ _invoke_command("test -f #{file.dump}", options)
37
+ rescue
38
+ logger.debug("assert_file_exists(#{file}) failed.")
39
+ _invoke_command("ls #{File.dirname(file).dump}", options)
40
+ raise
41
+ end
42
+ end
43
+
44
+ def assert_file_not_exists(file, options={})
45
+ begin
46
+ _invoke_command("test \! -f #{file.dump}", options)
47
+ rescue
48
+ logger.debug("assert_file_not_exists(#{file}) failed.")
49
+ _invoke_command("ls #{File.dirname(file).dump}", options)
50
+ raise
51
+ end
52
+ end
53
+
54
+ def assert_command(cmdline, options={})
55
+ begin
56
+ _invoke_command(cmdline, options)
57
+ rescue
58
+ logger.debug("assert_command(#{cmdline}) failed.")
59
+ raise
60
+ end
61
+ end
62
+
63
+ def assert_command_fails(cmdline, options={})
64
+ failed = false
65
+ begin
66
+ _invoke_command(cmdline, options)
67
+ rescue
68
+ logger.debug("assert_command_fails(#{cmdline}) failed.")
69
+ failed = true
70
+ ensure
71
+ abort unless failed
72
+ end
73
+ end
74
+
75
+ def reset_java!
76
+ variables.each_key do |key|
77
+ reset!(key) if /^java_/ =~ key
78
+ end
79
+ find_and_execute_task("java:setup_default_environment")
80
+ end
81
+
82
+ def uninstall_java!
83
+ run("rm -rf #{java_home.dump}")
84
+ run("rm -f #{java_archive_file.dump}")
85
+ run_locally("rm -rf #{java_home_local.dump}")
86
+ end
87
+
88
+ task(:test_all) {
89
+ find_and_execute_task("test_default")
90
+ find_and_execute_task("test_with_java5")
91
+ find_and_execute_task("test_with_java6")
92
+ find_and_execute_task("test_with_remote")
93
+ find_and_execute_task("test_with_local")
94
+ }
95
+
96
+ on(:start) {
97
+ run("rm -rf #{deploy_to.dump}")
98
+ }
99
+
100
+ namespace(:test_default) {
101
+ task(:default) {
102
+ methods.grep(/^test_/).each do |m|
103
+ send(m)
104
+ end
105
+ }
106
+ before "test_default", "test_default:setup"
107
+ after "test_default", "test_default:teardown"
108
+
109
+ task(:setup) {
110
+ reset_java!
111
+ # set(:java_version_name, "7u15")
112
+ set(:java_accept_license, true)
113
+ set(:java_license_title, "Oracle Binary Code License Agreement for Java SE")
114
+ set(:java_setup_remotely, true)
115
+ set(:java_setup_locally, true)
116
+ set(:java_installer_json_expires, 300)
117
+ set(:java_installer_json_keep_stale, false)
118
+ uninstall_java!
119
+ find_and_execute_task("deploy:setup")
120
+ }
121
+
122
+ task(:teardown) {
123
+ uninstall_java!
124
+ }
125
+
126
+ task(:test_run_java) {
127
+ assert_file_exists(java_bin)
128
+ assert_command("#{java_cmd} -version")
129
+ }
130
+
131
+ task(:test_run_java_via_sudo) {
132
+ assert_command("#{java_cmd} -version", :via => :sudo)
133
+ }
134
+
135
+ task(:test_run_java_without_path) {
136
+ assert_command("java -version")
137
+ }
138
+
139
+ task(:test_run_java_via_run_locally) {
140
+ assert_file_exists(java_bin_local, :via => :run_locally)
141
+ assert_command("#{java_cmd_local} -version", :via => :run_locally)
142
+ }
143
+ }
144
+
145
+ namespace(:test_with_java5) {
146
+ task(:default) {
147
+ methods.grep(/^test_/).each do |m|
148
+ send(m)
149
+ end
150
+ }
151
+ before "test_with_java5", "test_with_java5:setup"
152
+ after "test_with_java5", "test_with_java5:teardown"
153
+
154
+ task(:setup) {
155
+ reset_java!
156
+ set(:java_version_name, "1_5_0_22")
157
+ set(:java_accept_license, true)
158
+ set(:java_license_title, "Oracle Binary Code License Agreement for Java SE")
159
+ set(:java_setup_remotely, true)
160
+ set(:java_setup_locally, true)
161
+ set(:java_installer_json_expires, 300)
162
+ set(:java_installer_json_keep_stale, false)
163
+ uninstall_java!
164
+ find_and_execute_task("deploy:setup")
165
+ }
166
+
167
+ task(:teardown) {
168
+ uninstall_java!
169
+ }
170
+
171
+ task(:test_run_java) {
172
+ assert_file_exists(java_bin)
173
+ assert_command("#{java_cmd} -version")
174
+ }
175
+
176
+ task(:test_run_java_via_sudo) {
177
+ assert_command("#{java_cmd} -version", :via => :sudo)
178
+ }
179
+
180
+ task(:test_run_java_without_path) {
181
+ assert_command("java -version")
182
+ }
183
+
184
+ task(:test_run_java_via_run_locally) {
185
+ assert_file_exists(java_bin_local, :via => :run_locally)
186
+ assert_command("#{java_cmd_local} -version", :via => :run_locally)
187
+ }
188
+ }
189
+
190
+ namespace(:test_with_java6) {
191
+ task(:default) {
192
+ methods.grep(/^test_/).each do |m|
193
+ send(m)
194
+ end
195
+ }
196
+ before "test_with_java6", "test_with_java6:setup"
197
+ after "test_with_java6", "test_with_java6:teardown"
198
+
199
+ task(:setup) {
200
+ reset_java!
201
+ set(:java_version_name, "6u39")
202
+ set(:java_accept_license, true)
203
+ set(:java_license_title, "Oracle Binary Code License Agreement for Java SE")
204
+ set(:java_setup_remotely, true)
205
+ set(:java_setup_locally, true)
206
+ set(:java_installer_json_expires, 300)
207
+ set(:java_installer_json_keep_stale, false)
208
+ uninstall_java!
209
+ find_and_execute_task("deploy:setup")
210
+ }
211
+
212
+ task(:teardown) {
213
+ uninstall_java!
214
+ }
215
+
216
+ task(:test_run_java) {
217
+ assert_file_exists(java_bin)
218
+ assert_command("#{java_cmd} -version")
219
+ }
220
+
221
+ task(:test_run_java_via_sudo) {
222
+ assert_command("#{java_cmd} -version", :via => :sudo)
223
+ }
224
+
225
+ task(:test_run_java_without_path) {
226
+ assert_command("java -version")
227
+ }
228
+
229
+ task(:test_run_java_via_run_locally) {
230
+ assert_file_exists(java_bin_local, :via => :run_locally)
231
+ assert_command("#{java_cmd_local} -version", :via => :run_locally)
232
+ }
233
+ }
234
+
235
+ namespace(:test_with_remote) {
236
+ task(:default) {
237
+ methods.grep(/^test_/).each do |m|
238
+ send(m)
239
+ end
240
+ }
241
+ before "test_with_remote", "test_with_remote:setup"
242
+ after "test_with_remote", "test_with_remote:teardown"
243
+
244
+ task(:setup) {
245
+ reset_java!
246
+ # set(:java_version_name, "7u15")
247
+ set(:java_accept_license, true)
248
+ set(:java_license_title, "Oracle Binary Code License Agreement for Java SE")
249
+ set(:java_setup_remotely, true)
250
+ set(:java_setup_locally, false)
251
+ set(:java_installer_json_expires, 300)
252
+ set(:java_installer_json_keep_stale, false)
253
+ uninstall_java!
254
+ find_and_execute_task("deploy:setup")
255
+ }
256
+
257
+ task(:teardown) {
258
+ uninstall_java!
259
+ }
260
+
261
+ task(:test_run_java) {
262
+ assert_file_exists(java_bin)
263
+ assert_command("#{java_cmd} -version")
264
+ }
265
+
266
+ task(:test_run_java_via_run_locally) {
267
+ assert_file_not_exists(java_bin_local, :via => :run_locally)
268
+ assert_command_fails("#{java_cmd_local} -version", :via => :run_locally)
269
+ }
270
+ }
271
+
272
+ namespace(:test_with_local) {
273
+ task(:default) {
274
+ methods.grep(/^test_/).each do |m|
275
+ send(m)
276
+ end
277
+ }
278
+ before "test_with_local", "test_with_local:setup"
279
+ after "test_with_local", "test_with_local:teardown"
280
+
281
+ task(:setup) {
282
+ reset_java!
283
+ # set(:java_version_name, "7u15")
284
+ set(:java_accept_license, true)
285
+ set(:java_license_title, "Oracle Binary Code License Agreement for Java SE")
286
+ set(:java_setup_remotely, false)
287
+ set(:java_setup_locally, true)
288
+ set(:java_installer_json_expires, 300)
289
+ set(:java_installer_json_keep_stale, false)
290
+ uninstall_java!
291
+ find_and_execute_task("deploy:setup")
292
+ }
293
+
294
+ task(:teardown) {
295
+ uninstall_java!
296
+ }
297
+
298
+ task(:test_run_java) {
299
+ assert_file_not_exists(java_bin)
300
+ assert_command_fails("#{java_cmd} -version")
301
+ }
302
+
303
+ task(:test_run_java_via_run_locally) {
304
+ assert_file_exists(java_bin_local, :via => :run_locally)
305
+ assert_command("#{java_cmd_local} -version", :via => :run_locally)
306
+ }
307
+ }
308
+
309
+ # vim:set ft=ruby sw=2 ts=2 :
@@ -0,0 +1,5 @@
1
+ /.bundle
2
+ /.vagrant
3
+ /known_hosts
4
+ /tmp
5
+ /vendor
@@ -0,0 +1,2 @@
1
+ load "deploy"
2
+ load "../config/deploy"