capistrano-exfel 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -6
- data/Gemfile +3 -1
- data/README.md +2 -2
- data/Rakefile +2 -0
- data/capistrano-exfel.gemspec +5 -3
- data/capistrano.graph +86 -56
- data/capistrano.png +0 -0
- data/lib/capistrano/exfel.rb +2 -0
- data/lib/capistrano/exfel/co7.rb +3 -3
- data/lib/capistrano/exfel/version.rb +3 -1
- data/lib/capistrano/recipes/{co7 → apache}/00-passenger.conf +0 -0
- data/lib/capistrano/recipes/{ub14/apache.conf → apache/app_ssl.conf} +11 -4
- data/lib/capistrano/recipes/{co7 → apache}/httpd.conf +6 -0
- data/lib/capistrano/recipes/apache/ssl.conf +49 -0
- data/lib/capistrano/tasks/apache.rake +268 -0
- data/lib/capistrano/tasks/app_home.rake +2 -0
- data/lib/capistrano/tasks/application.rake +2 -0
- data/lib/capistrano/tasks/assets.rake +2 -0
- data/lib/capistrano/tasks/database.rake +2 -0
- data/lib/capistrano/tasks/secrets.rake +2 -0
- data/lib/capistrano/tasks/util.rake +2 -0
- metadata +14 -26
- data/lib/capistrano/exfel/sl6.rb +0 -21
- data/lib/capistrano/exfel/ub14.rb +0 -20
- data/lib/capistrano/recipes/apache_http.conf +0 -46
- data/lib/capistrano/recipes/apache_ssl.conf +0 -252
- data/lib/capistrano/recipes/co7/apache_http.conf +0 -7
- data/lib/capistrano/recipes/co7/apache_ssl.conf +0 -66
- data/lib/capistrano/recipes/ub14/passenger.conf +0 -6
- data/lib/capistrano/tasks/apache_co7.rake +0 -133
- data/lib/capistrano/tasks/apache_common.rake +0 -75
- data/lib/capistrano/tasks/apache_rpm.rake +0 -50
- data/lib/capistrano/tasks/apache_sl6.rake +0 -241
- data/lib/capistrano/tasks/apache_ub14.rake +0 -116
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d086fd4c9e4f16c7f68d37876de7ef24704e010fc19a41faec2447ecc86072b2
|
4
|
+
data.tar.gz: 01e8177b84dc63483b996d26e4ebd8cd7589ff7d0c6aaf1b6ff533f60d76ed56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83c826336eef52236f1d1f264a1a355916652023b583858e4fb949e6a1b7dd2b14203db5d8b37286aff507ad711df99f31eac896bee8403ed29962a1d3414b1b
|
7
|
+
data.tar.gz: 517745ce8bd5d2646f460582c48f4145749df2334ed17f177e99760ff92c00278546e835a3417e021748b36a00d5ef883784031c25d3c956beaacb64b3a9d14a
|
data/.rubocop.yml
CHANGED
@@ -24,12 +24,6 @@ Style/Lambda:
|
|
24
24
|
Metrics/BlockLength:
|
25
25
|
Max: 160 # Default 25
|
26
26
|
|
27
|
-
#
|
28
|
-
# Use 2 spaces for indentation in a heredoc by using some library(e.g. ActiveSupport's String#strip_heredoc).
|
29
|
-
Style/IndentHeredoc:
|
30
|
-
Exclude:
|
31
|
-
- 'lib/capistrano/tasks/apache_sl6.rake'
|
32
|
-
|
33
27
|
# Use meaningful heredoc delimiters.
|
34
28
|
Naming/HeredocDelimiterNaming:
|
35
29
|
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in capistrano-exfel.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
8
|
# Use Rubocop to validate ruby code syntax
|
7
|
-
gem 'rubocop', '0.
|
9
|
+
gem 'rubocop', '0.79.0', require: false, group: :development
|
data/README.md
CHANGED
@@ -9,8 +9,8 @@ Installation of Phusion Passenger and RVM are also required to this gem.
|
|
9
9
|
Add these lines to your application's Gemfile:
|
10
10
|
|
11
11
|
# Use Capistrano for deployment
|
12
|
-
gem 'capistrano', '3.11.
|
13
|
-
gem 'capistrano-exfel', '0.
|
12
|
+
gem 'capistrano', '3.11.2', require: false
|
13
|
+
gem 'capistrano-exfel', '0.3.0', require: false
|
14
14
|
gem 'capistrano-rails', '1.4.0', require: false
|
15
15
|
gem 'capistrano-rvm', '0.1.2', require: false
|
16
16
|
|
data/Rakefile
CHANGED
data/capistrano-exfel.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'capistrano/exfel/version'
|
@@ -9,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
9
11
|
spec.email = %w[luisgoncalo.maia@gmail.com maurizio.manetti@xfel.eu]
|
10
12
|
spec.summary = 'Deploy Ruby on Rails 4 and 5 Applications in EXFEL Virtual Machines'
|
11
13
|
spec.description = 'Deployment of Ruby on Rails Applications in EXFEL Virtual Machines ' \
|
12
|
-
'(
|
14
|
+
'(CentOS 7 + Apache + RVM + Phusion Passenger) ' \
|
13
15
|
'using Capistrano3 and LDAP'
|
14
16
|
spec.homepage = 'https://github.com/luismaia/capistrano-exfel'
|
15
17
|
spec.license = 'MIT'
|
@@ -19,6 +21,6 @@ Gem::Specification.new do |spec|
|
|
19
21
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
22
|
spec.require_paths = ['lib']
|
21
23
|
|
22
|
-
spec.add_development_dependency 'bundler', '~>
|
23
|
-
spec.add_development_dependency 'rake', '~>
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
25
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
24
26
|
end
|
data/capistrano.graph
CHANGED
@@ -1,66 +1,96 @@
|
|
1
1
|
digraph {
|
2
|
-
|
3
|
-
|
2
|
+
rankdir=LR;
|
3
|
+
ordering=out ;
|
4
|
+
edge [arrowhead=open;fontname=Arial;labeldistance=0];
|
4
5
|
node [shape=box;fontname=Arial];
|
6
|
+
// splines=ortho;
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
"application:deploy" -> deploy;
|
19
|
-
"application:deploy" -> "app_home:correct_shared_permissions";
|
20
|
-
"application:deploy" -> "application:restart";
|
21
|
-
|
22
|
-
"application:restart" -> "apache:restart";
|
23
|
-
"application:restart" -> "app_home:reload_server_cache";
|
24
|
-
"application:restart" -> "app_home:deploy_success_msg";
|
25
|
-
|
26
|
-
"application:reconfigure_apache" -> "apache_co7:configure";
|
27
|
-
"application:reconfigure_apache" -> "application:restart";
|
28
|
-
|
29
|
-
"app_home:create_all" -> "app_home:create_deploy_folder";
|
30
|
-
"app_home:create_all" -> "app_home:create_shared_folder";
|
31
|
-
"app_home:create_all" -> "app_home:create_revisions_file";
|
8
|
+
subgraph cluster_application {
|
9
|
+
labeljust="l";
|
10
|
+
label="application.rake";
|
11
|
+
fontname="Arial";
|
12
|
+
"application:deploy_first_time" -> "deploy"[label="7",color=orange];
|
13
|
+
"application:deploy_first_time" -> "application:restart"[label="9",color=brown];
|
14
|
+
"application:deploy" -> "deploy"[label="3",color=purple];
|
15
|
+
"application:deploy" -> "application:restart"[label="5",color=yellow];
|
16
|
+
"application:reconfigure_apache" -> "application:restart"[label="2",color=blue];
|
17
|
+
"application:show_variables";
|
18
|
+
"load:defaults";
|
19
|
+
}
|
32
20
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
21
|
+
subgraph cluster_apache {
|
22
|
+
label="apache.rake";
|
23
|
+
labeljust="l";
|
24
|
+
fontname="Arial";
|
25
|
+
"apache:configure_and_start" -> "apache:chkconfig_on"[label="2",color=blue];
|
26
|
+
"application:deploy_first_time" -> "apache:configure_and_start"[label="5",color=yellow];
|
27
|
+
"application:restart" -> "apache:restart"[label="1",color=black];
|
28
|
+
"application:reconfigure_apache" -> "apache:configure"[label="1",color=black];
|
29
|
+
"apache:configure_and_start" -> "apache:configure"[label="1",color=black];
|
30
|
+
"apache:configure" -> "apache:create_apache_sites_folder"[label="2",color=blue];
|
31
|
+
"apache:configure" -> "apache:configure_apache_modules"[label="3",color=purple];
|
32
|
+
"apache:configure" -> "apache:configure_app_ssl_conf_file"[label="4",color=red];
|
33
|
+
"apache:configure_and_start" -> "apache:secure_apache"[label="3",color=purple];
|
34
|
+
"apache:configure" -> "apache:create_apache_shared_folder"[label="1",color=black];
|
35
|
+
"apache:configure_and_start" -> "apache:create_symbolic_link"[label="4",color=red];
|
36
|
+
"application:deploy_first_time" -> "apache:check_write_permissions"[label="6",color=green];
|
37
|
+
"apache:check_write_permissions" -> "apache:check_write_permissions_on_deploy"[label="1",color=black];
|
38
|
+
"apache:check_write_permissions" -> "apache:check_write_permissions_on_document_root"[label="2",color=blue];
|
39
|
+
}
|
37
40
|
|
38
|
-
|
39
|
-
|
41
|
+
subgraph cluster_secrets {
|
42
|
+
label="secrets.rake";
|
43
|
+
labeljust="l";
|
44
|
+
fontname="Arial";
|
45
|
+
"application:deploy" -> "secrets:update_app_secret"[label="2",color=blue];
|
46
|
+
"secrets:update_app_secret" -> "secrets:set_permissions_pre_update"[label="1",color=black];
|
47
|
+
"secrets:update_app_secret" -> "secrets:replace_token"[label="2",color=blue];
|
48
|
+
"secrets:update_app_secret" -> "secrets:set_permissions_post_update"[label="3",color=purple];
|
49
|
+
"application:deploy_first_time" -> "secrets:configure"[label="4",color=red];
|
50
|
+
"secrets:configure" -> "secrets:set_permissions_pre_update"[label="1",color=black];
|
51
|
+
"secrets:configure" -> "secrets:set_secrets_file"[label="2",color=blue];
|
52
|
+
"secrets:configure" -> "secrets:replace_token"[label="3",color=purple];
|
53
|
+
"secrets:configure" -> "secrets:set_permissions_post_update"[label="4",color=red];
|
54
|
+
}
|
40
55
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
56
|
+
subgraph cluster_app_home {
|
57
|
+
label="app_home.rake";
|
58
|
+
labeljust="l";
|
59
|
+
fontname="Arial";
|
60
|
+
"application:deploy" -> "app_home:deploy_start_msg"[label="1",color=black];
|
61
|
+
"application:deploy_first_time" -> "app_home:deploy_first_time_start_msg"[label="1",color=black];
|
62
|
+
"application:deploy_first_time" -> "app_home:create_all"[label="2",color=blue];
|
63
|
+
"application:deploy_first_time" -> "app_home:correct_shared_permissions"[label="8",color=pink];
|
64
|
+
"app_home:create_all" -> "app_home:create_deploy_folder"[label="1",color=black];
|
65
|
+
"app_home:create_all" -> "app_home:create_shared_folder"[label="2",color=blue];
|
66
|
+
"app_home:create_all" -> "app_home:create_revisions_file"[label="3",color=purple];
|
67
|
+
"application:deploy" -> "app_home:correct_shared_permissions"[label="4",color=red];
|
68
|
+
"application:restart" -> "app_home:reload_server_cache"[label="2",color=blue];
|
69
|
+
"application:restart" -> "app_home:deploy_success_msg"[label="3",color=purple];
|
70
|
+
"app_home:correct_public_folder_permissions";
|
71
|
+
"app_home:clear_tmp_files";
|
72
|
+
"app_home:restart";
|
73
|
+
}
|
45
74
|
|
46
|
-
|
47
|
-
|
48
|
-
|
75
|
+
subgraph cluster_database {
|
76
|
+
label="database.rake";
|
77
|
+
labeljust="l";
|
78
|
+
fontname="Arial";
|
79
|
+
"application:deploy_first_time" -> "database:configure_mysql"[label="3",color=purple];
|
80
|
+
"database:configure_mysql" -> "database:configure_database_file";
|
81
|
+
"database:configure_database_file" -> "database:set_permissions_pre_update"[label="1",color=black];
|
82
|
+
"database:configure_database_file" -> "database:set_database_file"[label="2",color=blue];
|
83
|
+
"database:configure_database_file" -> "database:set_permissions_post_update"[label="3",color=purple];
|
84
|
+
"database:seed";
|
85
|
+
}
|
49
86
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
"secrets:configure" -> "secrets:set_permissions_post_update";
|
59
|
-
|
60
|
-
"secrets:update_app_secret" -> "secrets:set_permissions_pre_update";
|
61
|
-
"secrets:update_app_secret" -> "secrets:replace_token";
|
62
|
-
"secrets:update_app_secret" -> "secrets:set_permissions_post_update"
|
87
|
+
subgraph cluster_assets {
|
88
|
+
label="assets.rake";
|
89
|
+
labeljust="l";
|
90
|
+
fontname="Arial";
|
91
|
+
deploy -> "deploy:compile_assets";
|
92
|
+
"deploy:compile_assets" -> "deploy:assets_precompile"[label="1",color=black];
|
93
|
+
"deploy:compile_assets" -> "deploy:assets_backup_manifest"[label="2",color=blue];
|
94
|
+
}
|
63
95
|
|
64
96
|
}
|
65
|
-
|
66
|
-
|
data/capistrano.png
CHANGED
Binary file
|
data/lib/capistrano/exfel.rb
CHANGED
data/lib/capistrano/exfel/co7.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Load DSL and Setup Up Stages
|
2
4
|
require 'capistrano/setup'
|
3
5
|
|
@@ -10,9 +12,7 @@ require 'capistrano/rvm'
|
|
10
12
|
# Includes tasks for rails
|
11
13
|
require 'capistrano/rails'
|
12
14
|
|
13
|
-
load File.expand_path('../tasks/
|
14
|
-
load File.expand_path('../tasks/apache_rpm.rake', __dir__)
|
15
|
-
load File.expand_path('../tasks/apache_co7.rake', __dir__)
|
15
|
+
load File.expand_path('../tasks/apache.rake', __dir__)
|
16
16
|
load File.expand_path('../tasks/app_home.rake', __dir__)
|
17
17
|
load File.expand_path('../tasks/assets.rake', __dir__)
|
18
18
|
load File.expand_path('../tasks/application.rake', __dir__)
|
File without changes
|
@@ -1,15 +1,22 @@
|
|
1
|
+
# <<APPLICATION_NAME>> - Ruby on Rails Application
|
2
|
+
#
|
3
|
+
# Application secured by SSL
|
4
|
+
|
1
5
|
Alias /<<APPLICATION_NAME>> /var/www/html/<<APPLICATION_NAME>>
|
2
6
|
|
3
7
|
#
|
4
|
-
# Application
|
8
|
+
# Application configuration
|
5
9
|
#
|
6
|
-
|
7
|
-
<Directory "/var/www/html/<<APPLICATION_NAME>>">
|
10
|
+
<Directory "/var/www/html/<<APPLICATION_NAME>>/">
|
8
11
|
RackBaseURI /<<APPLICATION_NAME>>
|
9
12
|
RailsEnv <<ENVIRONMENT>>
|
10
13
|
|
11
14
|
PassengerUser nobody
|
12
|
-
|
15
|
+
# CentOS: nobody / Ubuntu/Debian: nogroup
|
16
|
+
PassengerGroup nobody
|
17
|
+
|
18
|
+
# which ruby version to use
|
19
|
+
PassengerRuby <<RUBY_PATH>>
|
13
20
|
|
14
21
|
# This relaxes Apache security settings.
|
15
22
|
Options -Indexes +MultiViews +FollowSymLinks
|
@@ -27,6 +27,12 @@ DocumentRoot "/var/www/html"
|
|
27
27
|
Options Indexes FollowSymLinks
|
28
28
|
AllowOverride None
|
29
29
|
Require all granted
|
30
|
+
|
31
|
+
# Redirect all HTTP to https://%{SERVER_NAME}/, keeping the requested path
|
32
|
+
RewriteEngine On
|
33
|
+
RewriteCond %{HTTPS} !=on
|
34
|
+
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
|
35
|
+
|
30
36
|
</Directory>
|
31
37
|
|
32
38
|
<IfModule dir_module>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
Listen 443 https
|
2
|
+
|
3
|
+
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog
|
4
|
+
|
5
|
+
SSLSessionCache shmcb:/run/httpd/sslcache(512000)
|
6
|
+
SSLSessionCacheTimeout 300
|
7
|
+
|
8
|
+
SSLRandomSeed startup file:/dev/urandom 256
|
9
|
+
SSLRandomSeed connect builtin
|
10
|
+
|
11
|
+
SSLCryptoDevice builtin
|
12
|
+
|
13
|
+
##
|
14
|
+
## SSL Virtual Host Context
|
15
|
+
##
|
16
|
+
|
17
|
+
<VirtualHost _default_:443>
|
18
|
+
|
19
|
+
ErrorLog logs/ssl_error_log
|
20
|
+
LogLevel warn
|
21
|
+
|
22
|
+
SSLEngine on
|
23
|
+
|
24
|
+
SSLProtocol all -SSLv2 -SSLv3
|
25
|
+
|
26
|
+
SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA
|
27
|
+
|
28
|
+
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
|
29
|
+
|
30
|
+
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
|
31
|
+
|
32
|
+
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
|
33
|
+
SSLOptions +StdEnvVars
|
34
|
+
</Files>
|
35
|
+
<Directory "/var/www/cgi-bin">
|
36
|
+
SSLOptions +StdEnvVars
|
37
|
+
</Directory>
|
38
|
+
|
39
|
+
BrowserMatch "MSIE [2-5]" \
|
40
|
+
nokeepalive ssl-unclean-shutdown \
|
41
|
+
downgrade-1.0 force-response-1.0
|
42
|
+
|
43
|
+
RemoteIPHeader X-Forwarded-For
|
44
|
+
LogFormat "%t - %a - %s - %{Host}i - \"%r\" \"%{Referer}i\" \"%{User-agent}i\" %D" xfel
|
45
|
+
CustomLog logs/ssl_access_log xfel
|
46
|
+
|
47
|
+
IncludeOptional sites.d/*.conf
|
48
|
+
|
49
|
+
</VirtualHost>
|
@@ -0,0 +1,268 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# apache tasks
|
4
|
+
|
5
|
+
namespace :apache do
|
6
|
+
desc 'Configure Apache (httpd) and restart it'
|
7
|
+
task :configure_and_start do
|
8
|
+
invoke 'apache:configure'
|
9
|
+
invoke 'apache:chkconfig_on' # This task should go to Puppet or installation script
|
10
|
+
invoke 'apache:replace_apache_defaults' # This task should go to Puppet or installation script
|
11
|
+
invoke 'apache:create_symbolic_link'
|
12
|
+
end
|
13
|
+
|
14
|
+
# This task should be moved into Puppet or the installation script
|
15
|
+
desc 'Configure Apache to start at bootup'
|
16
|
+
task :chkconfig_on do
|
17
|
+
on roles(:web) do
|
18
|
+
info 'In task apache:chkconfig_on'
|
19
|
+
|
20
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
21
|
+
|
22
|
+
debug '#' * 50
|
23
|
+
|
24
|
+
debug 'chkconfig httpd on'
|
25
|
+
execute "#{sudo_cmd} chkconfig httpd on"
|
26
|
+
|
27
|
+
info 'Configured Apache to start at bootup'
|
28
|
+
debug '#' * 50
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Restart Apache (httpd) service'
|
33
|
+
task :restart do
|
34
|
+
on roles(:web) do
|
35
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
36
|
+
|
37
|
+
debug '#' * 50
|
38
|
+
|
39
|
+
debug 'service httpd stop'
|
40
|
+
execute "#{sudo_cmd} service httpd stop"
|
41
|
+
|
42
|
+
debug 'pkill -9 httpd || true'
|
43
|
+
execute "#{sudo_cmd} pkill -9 httpd || true"
|
44
|
+
|
45
|
+
debug 'service httpd start'
|
46
|
+
execute "#{sudo_cmd} service httpd start"
|
47
|
+
|
48
|
+
info 'Restarted Apache (httpd) service'
|
49
|
+
debug '#' * 50
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Configure Apache configuration files'
|
54
|
+
task :configure do
|
55
|
+
invoke 'apache:create_apache_shared_folder'
|
56
|
+
invoke 'apache:create_apache_sites_folder'
|
57
|
+
invoke 'apache:configure_apache_modules'
|
58
|
+
invoke 'apache:configure_app_ssl_conf_file'
|
59
|
+
end
|
60
|
+
|
61
|
+
# This task should be moved into Puppet or the installation script
|
62
|
+
desc 'Create Apache multi-site configuration folder'
|
63
|
+
task :create_apache_sites_folder do
|
64
|
+
on roles(:app) do
|
65
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
66
|
+
|
67
|
+
debug '#' * 50
|
68
|
+
debug 'Create Apache multi-site configuration folder'
|
69
|
+
|
70
|
+
debug 'mkdir -p /etc/httpd/sites.d'
|
71
|
+
execute "#{sudo_cmd} mkdir -p /etc/httpd/sites.d"
|
72
|
+
|
73
|
+
debug '#' * 50
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# This task should be moved into Puppet or the installation script
|
78
|
+
desc 'Configure Apache modules'
|
79
|
+
task :configure_apache_modules do
|
80
|
+
on roles(:app) do
|
81
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
82
|
+
|
83
|
+
debug '#' * 50
|
84
|
+
debug 'Configure (HTTP) Apache Passenger module'
|
85
|
+
|
86
|
+
set :shared_passenger_file, '/etc/httpd/conf.modules.d/00-passenger.conf'
|
87
|
+
passenger_file = File.expand_path('../recipes/apache/00-passenger.conf', __dir__)
|
88
|
+
|
89
|
+
# Create a temporary copy of the passenger module file
|
90
|
+
set :tmp_passenger_file, '/tmp/00-passenger.conf'
|
91
|
+
|
92
|
+
upload! StringIO.new(File.read(passenger_file)), fetch(:tmp_passenger_file).to_s
|
93
|
+
|
94
|
+
passenger_root = get_command_output("/usr/local/rvm/bin/rvm #{fetch(:rvm_ruby_version)} do passenger-config --root")
|
95
|
+
ruby_path = "/#{passenger_root.split('/')[1..5].join('/')}/wrappers/ruby"
|
96
|
+
|
97
|
+
debug "sed -i 's|<<PASSENGER_ROOT>>|#{passenger_root}|g' #{fetch(:tmp_passenger_file)}"
|
98
|
+
execute "sed -i 's|<<PASSENGER_ROOT>>|#{passenger_root}|g' #{fetch(:tmp_passenger_file)}"
|
99
|
+
execute "sed -i 's|<<RUBY_PATH>>|#{ruby_path}|g' #{fetch(:tmp_passenger_file)}"
|
100
|
+
|
101
|
+
# Replace the passenger module file
|
102
|
+
execute "#{sudo_cmd} mv -f #{fetch(:tmp_passenger_file)} #{fetch(:shared_passenger_file)}"
|
103
|
+
execute "#{sudo_cmd} chown root.root #{fetch(:shared_passenger_file)}"
|
104
|
+
|
105
|
+
debug '#' * 50
|
106
|
+
debug 'Deactivate unnecessary Apache modules'
|
107
|
+
%w[00-dav.conf 00-lua.conf 00-proxy.conf 01-cgi.conf].each do |file|
|
108
|
+
if remote_file_exists?("/etc/httpd/conf.modules.d/#{file}")
|
109
|
+
# only perform backup of Apache modules files unless already done
|
110
|
+
unless remote_file_exists?("/etc/httpd/conf.modules.d/#{file}_bck")
|
111
|
+
execute "#{sudo_cmd} cp /etc/httpd/conf.modules.d/#{file} /etc/httpd/conf.modules.d/#{file}_bck"
|
112
|
+
end
|
113
|
+
execute "#{sudo_cmd} truncate -s 0 /etc/httpd/conf.modules.d/#{file}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
debug '#' * 50
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
desc 'Configure (HTTPS) Apache Application configuration files'
|
121
|
+
task :configure_app_ssl_conf_file do
|
122
|
+
on roles(:app), in: :sequence do
|
123
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
124
|
+
|
125
|
+
debug '#' * 50
|
126
|
+
debug 'Configure (HTTPS) Apache Application configuration files'
|
127
|
+
|
128
|
+
set :shared_apache_conf_ssl_file, "#{fetch(:shared_apache_path)}/app_#{fetch(:app_name_uri)}_ssl.conf"
|
129
|
+
http_ssl_file = File.expand_path('../recipes/apache/app_ssl.conf', __dir__)
|
130
|
+
upload! StringIO.new(File.read(http_ssl_file)), fetch(:shared_apache_conf_ssl_file).to_s
|
131
|
+
|
132
|
+
debug "chmod g+w #{fetch(:shared_apache_conf_ssl_file)}"
|
133
|
+
execute "chmod g+w #{fetch(:shared_apache_conf_ssl_file)}"
|
134
|
+
|
135
|
+
passenger_root = get_command_output("/usr/local/rvm/bin/rvm #{fetch(:rvm_ruby_version)} do passenger-config --root")
|
136
|
+
ruby_path = "/#{passenger_root.split('/')[1..5].join('/')}/wrappers/ruby"
|
137
|
+
|
138
|
+
execute "sed -i 's/<<APPLICATION_NAME>>/#{fetch(:app_name_uri)}/g' #{fetch(:shared_apache_conf_ssl_file)}"
|
139
|
+
execute "sed -i 's/<<ENVIRONMENT>>/#{fetch(:environment)}/g' #{fetch(:shared_apache_conf_ssl_file)}"
|
140
|
+
execute "sed -i 's|<<RUBY_PATH>>|#{ruby_path}|g' #{fetch(:shared_apache_conf_ssl_file)}"
|
141
|
+
|
142
|
+
execute "#{sudo_cmd} ln -sfn #{fetch(:shared_apache_conf_ssl_file)} /etc/httpd/sites.d/"
|
143
|
+
|
144
|
+
debug '#' * 50
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# This task should be moved into Puppet or the installation script
|
149
|
+
desc 'Replace CentOS 7 default httpd.conf and ssl.conf file with our version'
|
150
|
+
task :replace_apache_defaults do
|
151
|
+
on roles(:web) do
|
152
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
153
|
+
|
154
|
+
debug '#' * 50
|
155
|
+
debug 'Update httpd.conf and ssl.conf'
|
156
|
+
|
157
|
+
set :httpd_conf_file, '/etc/httpd/conf/httpd.conf'
|
158
|
+
|
159
|
+
# Replace the original Apache configuration file
|
160
|
+
if remote_file_exists?('/etc/httpd/conf/httpd.conf_bck')
|
161
|
+
info 'Apache original configuration file already backed up at: /etc/httpd/conf/httpd.conf_bck'
|
162
|
+
else
|
163
|
+
execute "#{sudo_cmd} cp -f #{fetch(:httpd_conf_file)} /etc/httpd/conf/httpd.conf_bck"
|
164
|
+
info 'Apache original configuration file backed up at: /etc/httpd/conf/httpd.conf_bck'
|
165
|
+
end
|
166
|
+
|
167
|
+
# Create a temporary copy of the Apache configuration file
|
168
|
+
set :tmp_httpd_file, '/tmp/httpd.conf'
|
169
|
+
httpd_safe_file = File.expand_path('../recipes/apache/httpd.conf', __dir__)
|
170
|
+
|
171
|
+
upload! StringIO.new(File.read(httpd_safe_file)), fetch(:tmp_httpd_file).to_s
|
172
|
+
|
173
|
+
# Replace the original Apache configuration file
|
174
|
+
execute "#{sudo_cmd} mv -f #{fetch(:tmp_httpd_file)} #{fetch(:httpd_conf_file)}"
|
175
|
+
|
176
|
+
set :ssl_conf_file, '/etc/httpd/conf.d/ssl.conf'
|
177
|
+
|
178
|
+
# Replace the original Apache ssl configuration file
|
179
|
+
if remote_file_exists?('/etc/httpd/conf.d/ssl.conf_bck')
|
180
|
+
info 'Apache original ssl configuration file already backed up at: /etc/httpd/conf.d/ssl.conf_bck'
|
181
|
+
else
|
182
|
+
execute "#{sudo_cmd} cp -f #{fetch(:ssl_conf_file)} /etc/httpd/conf.d/ssl.conf_bck"
|
183
|
+
info 'Apache original ssl configuration file backed up at: /etc/httpd/conf.d/ssl.conf_bck'
|
184
|
+
end
|
185
|
+
|
186
|
+
# Create a temporary copy of the Apache ssl configuration file
|
187
|
+
set :tmp_ssl_file, '/tmp/ssl.conf'
|
188
|
+
ssl_safe_file = File.expand_path('../recipes/apache/ssl.conf', __dir__)
|
189
|
+
|
190
|
+
upload! StringIO.new(File.read(ssl_safe_file)), fetch(:tmp_ssl_file).to_s
|
191
|
+
|
192
|
+
# Replace the original Apache ssl configuration file
|
193
|
+
execute "#{sudo_cmd} mv -f #{fetch(:tmp_ssl_file)} #{fetch(:ssl_conf_file)}"
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
desc 'Check that the user has write permissions in the Deploy and in Apache DocumentRoot folders'
|
198
|
+
task :check_write_permissions do
|
199
|
+
invoke 'apache:check_write_permissions_on_deploy'
|
200
|
+
invoke 'apache:check_write_permissions_on_document_root'
|
201
|
+
end
|
202
|
+
|
203
|
+
desc 'Check that we have the right permission to the folder the app should be deployed to'
|
204
|
+
task :check_write_permissions_on_deploy do
|
205
|
+
on roles(:app), in: :sequence do |host|
|
206
|
+
debug '#' * 50
|
207
|
+
debug "Checking folder '#{fetch(:deploy_to)}' (where the application has to be deployed) "\
|
208
|
+
"for the right permissions on Host '#{host}'"
|
209
|
+
|
210
|
+
if test("[ -w #{fetch(:deploy_to)} ]")
|
211
|
+
info "#{fetch(:deploy_to)} is writable on #{host}"
|
212
|
+
else
|
213
|
+
error "#{fetch(:deploy_to)} is not writable on #{host}"
|
214
|
+
end
|
215
|
+
|
216
|
+
debug '#' * 50
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
desc 'Check that we have the right permission to the Apache DocumentRoot folder'
|
221
|
+
task :check_write_permissions_on_document_root do
|
222
|
+
on roles(:web) do |host|
|
223
|
+
debug '#' * 50
|
224
|
+
debug "Checking Apache DocumentRoot folder (#{fetch(:apache_document_root)}) permissions on Host '#{host}'"
|
225
|
+
|
226
|
+
if test("[ -w #{fetch(:apache_document_root)} ]")
|
227
|
+
info "#{fetch(:apache_document_root)} is writable on #{host}"
|
228
|
+
else
|
229
|
+
info "#{fetch(:apache_document_root)} is not writable on #{host}"
|
230
|
+
end
|
231
|
+
|
232
|
+
debug '#' * 50
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
desc 'Create Apache configuration files shared folder'
|
237
|
+
task :create_apache_shared_folder do
|
238
|
+
on roles(:app) do
|
239
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
240
|
+
|
241
|
+
debug '#' * 50
|
242
|
+
debug 'Create Apache configuration files shared folder'
|
243
|
+
|
244
|
+
debug "mkdir -p #{fetch(:shared_apache_path)}"
|
245
|
+
execute "#{sudo_cmd} mkdir -p #{fetch(:shared_apache_path)}"
|
246
|
+
|
247
|
+
debug "chmod g+ws #{fetch(:shared_apache_path)}"
|
248
|
+
execute "#{sudo_cmd} chmod g+ws #{fetch(:shared_apache_path)}"
|
249
|
+
|
250
|
+
debug '#' * 50
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
desc 'Create symbolic link to application public folder in Apache DocumentRoot folder'
|
255
|
+
task :create_symbolic_link do
|
256
|
+
on roles(:web), in: :sequence do
|
257
|
+
sudo_cmd = "echo #{fetch(:password)} | sudo -S"
|
258
|
+
|
259
|
+
info '#' * 50
|
260
|
+
info 'Creating application symbolic link'
|
261
|
+
|
262
|
+
debug "ln -sfn #{fetch(:deploy_to)}/current/public #{fetch(:apache_deploy_symbolic_link)}"
|
263
|
+
execute "#{sudo_cmd} ln -sfn #{fetch(:deploy_to)}/current/public #{fetch(:apache_deploy_symbolic_link)}"
|
264
|
+
|
265
|
+
info '#' * 50
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|