capistrano-psw 1.0.0.pre32 → 1.0.0.pre33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d01081943f864d84807135605d48b146cd5c2b45
4
- data.tar.gz: ea7389d436a56f1303dc9ac45d1b109365296adc
3
+ metadata.gz: 9a6bb05a51b8f52e1d0794467c9f899642d06359
4
+ data.tar.gz: 3ef12e185ea7a4dca4a15e4a7d472c8e6c37154b
5
5
  SHA512:
6
- metadata.gz: 1fd791a3ddfd38e29adcf83ee113baf39a8cd79f5f1ab949e2f59eadb9738cecc628d14d3e6820a140d6649bcd603de5673c4a0c6bd85e5593dd27d9f7711b94
7
- data.tar.gz: 6e45dd4eea06315d013629b44e7b99d32700b4dd042cadd05f9ea4d35462b8aad690264a309ef0892b0995319acfb9ae7f36d3b812401b51217afc04ee27f53f
6
+ metadata.gz: d0deda336d97eb31dc1020954c9b464a5a3d16bc69059a55089c5b419efff15d9fe55f4d894f9ed64404b62c33518b5c326586dbfbd32b190fb261800e6b0b37
7
+ data.tar.gz: 79a7d0e87ad864eaf211f70fa10ef6a5fc7682157346efb21d781d11f158b5479c30606f3014c5de52ee6b6bc8cbf0ffc7b2499e9c63f97fa755b99ac7bb2f9e
data/README.md CHANGED
@@ -306,6 +306,29 @@ Parameters:
306
306
  *explode_directory [String] - The directory to which the exploded contents will be written
307
307
  *war_file_location [String] - The absolute path of the WAR file.
308
308
 
309
+ ### psw_javaee:deploy_ssl_certs
310
+ This task will copy SSL certificates defined in the application's shared directory
311
+ to /etc/ssl/certs and /etc/ssl/private. a Java Keystore will be created for Tomcat's reference.
312
+ The task takes the following parameters:
313
+ *[String] ssl_cert_file - the path to the SSL certificate file
314
+ *[String] ssl_key_file - the path to the SSL key file
315
+ *[String] ssl_chain_file - the path to the SSL chain file
316
+ *[String] keystore_password - the password that should be used to secure the keystore.
317
+ The default value is 'changeit'.
318
+ *[String] keystore_file - the file path of the keystore.
319
+ The default value '/<Capistrano Shared Path>/tomcat/keystore.jks'
320
+
321
+ ### psw_javaee:configure_tomcat
322
+ This task task will override the Tomcat server definition. This method allows consumers to
323
+ define an ERB template as well as pass in a ruby binding to populate it.
324
+ The task takes the following parameters:
325
+
326
+ *[Object] template_binding - the Ruby binding used for the Template
327
+ *[String] tomcat_config_template_path - path to the server template
328
+ *[String] config_filename - the name of the configuration file
329
+ *[String] tomcat_config_file_dir - The subdirectory in /<Capistrano Shared Path> which
330
+ will hold the completed file.
331
+
309
332
  ## License
310
333
 
311
334
  2014 Lexmark International Technology S.A. All rights reserved.
@@ -10,6 +10,6 @@
10
10
 
11
11
  module Capistrano
12
12
  module Psw
13
- VERSION = "1.0.0.pre32"
13
+ VERSION = "1.0.0.pre33"
14
14
  end
15
15
  end
@@ -12,6 +12,30 @@
12
12
  # *explode_directory [String] - The directory to which the exploded contents will be written
13
13
  # *war_file_location [String] - The absolute path of the WAR file.
14
14
  #
15
+ # === psw_javaee:deploy_ssl_certs
16
+ # This task will copy SSL certificates defined in the application's shared directory
17
+ # to /etc/ssl/certs and /etc/ssl/private. a Java Keystore will be created for Tomcat's reference.
18
+ # The task takes the following parameters:
19
+ #
20
+ # @param [String] ssl_cert_file - the path to the SSL certificate file
21
+ # @param [String] ssl_key_file - the path to the SSL key file
22
+ # @param [String] ssl_chain_file - the path to the SSL chain file
23
+ # @param [String] keystore_password - the password that should be used to secure the keystore.
24
+ # The default value is 'changeit'.
25
+ # @param [String] keystore_file - the file path of the keystore.
26
+ # The default value '/<Capistrano Shared Path>/tomcat/keystore.jks'
27
+ #
28
+ # === psw_javaee:configure_tomcat
29
+ # This task task will override the Tomcat server definition. This method allows consumers to
30
+ # define an ERB template as well as pass in a ruby binding to populate it.
31
+ # The task takes the following parameters:
32
+ #
33
+ # @param [Object] template_binding - the Ruby binding used for the Template
34
+ # @param [String] tomcat_config_template_path - path to the server template
35
+ # @param [String] config_filename - the name of the configuration file
36
+ # @param [String] tomcat_config_file_dir - The subdirectory in /<Capistrano Shared Path> which
37
+ # will hold the completed file.
38
+ #
15
39
  # == Contact
16
40
  #
17
41
  # Author:: Lexmark International Technology S.A.
@@ -30,4 +54,85 @@ namespace :psw_javaee do
30
54
  execute("cd #{args[:explode_directory]} ; /usr/bin/jar xf #{args[:war_file_location]}")
31
55
  end
32
56
  end
57
+
58
+ task :deploy_ssl_certs, :ssl_cert_file, :ssl_key_file, :ssl_chain_file, :keystore_password, :keystore_file do |t, args|
59
+ on roles(:app) do |host|
60
+ info "Creating cert directory..."
61
+ ssl_cert_dir = "/etc/ssl/certs"
62
+ sudo :mkdir, '-p', ssl_cert_dir
63
+
64
+ ssl_private_dir = "/etc/ssl/private"
65
+ info "Creating cert key directory..."
66
+ sudo :mkdir, '-p', ssl_private_dir
67
+
68
+ ssl_cert_filename = Pathname.new(args[:ssl_cert_file]).basename
69
+ ssl_cert_path = "#{ssl_cert_dir}/#{ssl_cert_filename}"
70
+ info "Copying certificate (#{args[:ssl_cert_file]}) to key directory..."
71
+ sudo :rm, "-rf", ssl_cert_path
72
+ sudo :cp, args[:ssl_cert_file], ssl_cert_dir
73
+ sudo :chmod, '600', ssl_cert_path
74
+
75
+ ssl_key_filename = Pathname.new(args[:ssl_key_file]).basename
76
+ ssl_key_path = "#{ssl_private_dir}/#{ssl_key_filename}"
77
+ info "Copying certificate key (#{args[:ssl_key_file]}) to key directory..."
78
+ sudo :rm, '-rf', ssl_key_path
79
+ sudo :cp, args[:ssl_key_file], ssl_private_dir
80
+ sudo :chmod, '600', ssl_key_path
81
+
82
+ ssl_chain_filename = Pathname.new(args[:ssl_chain_file]).basename
83
+ ssl_chain_path = "#{ssl_cert_dir}/#{ssl_chain_filename}"
84
+ info "Copying certificate chain (#{args[:ssl_chain_file]}) to cert directory..."
85
+ sudo :rm, '-rf', ssl_chain_path
86
+ sudo :cp, args[:ssl_chain_file], ssl_cert_dir
87
+ sudo :chmod, '600', ssl_chain_path
88
+
89
+ info "Creating certificate keystore..."
90
+ keystore_password = args[:keystore_password] unless args[:keystore_password].nil?
91
+ password ||= "changeit"
92
+
93
+ keystore_file = args[:keystore_file] unless args[:keystore_file].nil?
94
+ keystore_file ||= File.join("#{shared_path}","/tomcat/keystore.jks")
95
+
96
+ sudo("openssl pkcs12 -inkey #{ssl_key_path} -in #{ssl_cert_path} -CAfile #{ssl_chain_path} -chain -export -out #{keystore_file} -password pass:#{args[:keystore_password]}")
97
+ end
98
+ end
99
+
100
+ task :configure_tomcat, :template_binding, :tomcat_config_template_path, :config_filename, :tomcat_config_file_dir do |t, args|
101
+ on roles(:app) do |host|
102
+ info "Configuring tomcat..."
103
+
104
+ config_template_path = args[:tomcat_config_template_path]
105
+ unless config_template_path.nil? || config_template_path.length == 0
106
+ config_filename = args[:config_filename]
107
+
108
+ info "Adding server template #{config_template_path} to tomcat..."
109
+
110
+ config_template = ERB.new File.new(config_template_path).read, nil, "%"
111
+ template_binding = (!args[:template_binding].nil? && args[:template_binding]) || binding
112
+ config_file = config_template.result(template_binding)
113
+
114
+ tmp_site_file = Tempfile.new("#{config_filename}-")
115
+ tmp_site_file.write(config_file)
116
+ tmp_site_file.flush
117
+
118
+ shared_tomcat_config_dir = File.join("#{shared_path}","#{args[:tomcat_config_file_dir]}")
119
+ shared_tomcat_config_file = File.join("#{shared_tomcat_config_dir}","#{config_filename}")
120
+
121
+ info "Creating shared tomcat configuration directory #{shared_tomcat_config_dir}..."
122
+ execute :mkdir, '-p', shared_tomcat_config_dir
123
+
124
+ info "Uploading tomcat server configuration #{config_filename}..."
125
+ upload! "#{tmp_site_file.path}", "#{shared_tomcat_config_file}"
126
+ sudo :chmod, '0755', shared_tomcat_config_file
127
+
128
+ #symlink to config file
129
+ tomcat_config_file = File.join("/etc/tomcat7","#{config_filename}")
130
+ info "Creating a symlink from shared server configuration file #{shared_tomcat_config_file} as #{tomcat_config_file}..."
131
+ sudo :rm, '-rf', tomcat_config_file
132
+ sudo :ln, '-s', shared_tomcat_config_file, tomcat_config_file
133
+ else
134
+ info "A server template has not been defined for tomcat"
135
+ end
136
+ end
137
+ end
33
138
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-psw
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre32
4
+ version: 1.0.0.pre33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lexmark International Technology S.A
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-05 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler