avm-tools 0.19.0 → 0.20.0

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
  SHA256:
3
- metadata.gz: 0ecbab04ccca2c30b62ceb4a779d86ef11590ad4e82558593d42e2cc10e17deb
4
- data.tar.gz: 1b7dd104d1f0f81d32212a74ad3e6bed6c43d44d1b82c689ec06ab8ef3f7fa3c
3
+ metadata.gz: 243acbdeb6bf47023be05c689219226cb43d7d688b660f4239d3371ef0c8f77d
4
+ data.tar.gz: 60bf3e35ee6372cfaff53f9e37851087575ffee5906078307e6e73bfbf2e3b69
5
5
  SHA512:
6
- metadata.gz: c06af4841c27bdfb6847dc521c18a0283ae85df3615714976d95b1aac461b70e9c4c808409b13a76fde3918f1835ef568e2e9751e4edf5ed5b549c969cca727b
7
- data.tar.gz: 163f4a885519835eb5fdc794e7a7a919ac2c1be7782be0e47b2493859fd1734e576e5ba634caac342d9b1b144af7d0917b1f8c23a70486c510aeb4e42c37aa8f
6
+ metadata.gz: 38b11f783aab60e1d7008fe0925c8782f1e2833d9e071d93bdc322b3a475863e47b57e308650febf5dcb06c095402d43d345d31f6d8b0032ed1751d638ca13c0
7
+ data.tar.gz: bd3f4ec62f6e1b30559a309d8cd44c6ceb565aa4e7413be3b85d0ff4251927977884259f8cec8d51b0f7de56a4566f8f851b42f3a83f4b5a489ea36fdeaec498
@@ -10,7 +10,7 @@ module Avm
10
10
  extend ::ActiveSupport::Concern
11
11
 
12
12
  included do
13
- %w[Access Database Filesystem Source].each do |class_name|
13
+ %w[Access Admin Database Filesystem Source Web].each do |class_name|
14
14
  include const_get(class_name)
15
15
  end
16
16
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ module Instances
5
+ class Base
6
+ module AutoValues
7
+ module Admin
8
+ def auto_admin_email
9
+ inherited_entry_value(:host_id, 'admin.email')
10
+ end
11
+
12
+ def auto_admin_name
13
+ inherited_entry_value(:host_id, 'admin.name')
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable'
4
+
5
+ module Avm
6
+ module Instances
7
+ class Base
8
+ module AutoValues
9
+ module Web
10
+ def auto_web_hostname
11
+ read_entry_optional('web.url').if_present do |v|
12
+ ::Addressable::URI.parse(v).host
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/stereotypes/eac_ubuntu_base0/apache'
5
+ require 'avm/templates/file'
6
+
7
+ module Avm
8
+ module Stereotypes
9
+ module EacRailsBase0
10
+ class ApacheHost
11
+ enable_console_speaker
12
+ enable_simple_cache
13
+ common_constructor :instance
14
+
15
+ def run
16
+ write_available_no_ssl_site
17
+ enable_no_ssl_site
18
+ remove_ssl_site
19
+ reload_apache
20
+ run_certbot
21
+ enable_ssl_site
22
+ reload_apache
23
+ ::Avm::Result.success('Done')
24
+ end
25
+
26
+ private
27
+
28
+ def apache_uncached
29
+ ::Avm::Stereotypes::EacUbuntuBase0::Apache.new(instance.host_env)
30
+ end
31
+
32
+ def enable_no_ssl_site
33
+ infom 'Enabling no SSL site...'
34
+ no_ssl_site.enable
35
+ end
36
+
37
+ def enable_ssl_site
38
+ infom 'Enabling SSL site...'
39
+ ssl_site.enable
40
+ end
41
+
42
+ def no_ssl_site_content
43
+ ::Avm::Templates::File.new(
44
+ ::File.join(template_path, 'no_ssl.conf')
45
+ ).apply(instance)
46
+ end
47
+
48
+ def no_ssl_site_uncached
49
+ apache.site(instance.id)
50
+ end
51
+
52
+ def reload_apache
53
+ infom 'Reloading Apache...'
54
+ apache.service('reload')
55
+ end
56
+
57
+ def remove_ssl_site
58
+ infom 'Removing SSL site...'
59
+ ssl_site.remove
60
+ end
61
+
62
+ def run_certbot
63
+ infom 'Running Certbot...'
64
+ instance.host_env.command(
65
+ 'sudo', 'certbot', '--apache', '--domain', instance.read_entry('web.hostname'),
66
+ '--redirect', '--non-interactive', '--agree-tos',
67
+ '--email', instance.read_entry('admin.email')
68
+ ).system!
69
+ end
70
+
71
+ def ssl_site_uncached
72
+ apache.site(no_ssl_site.name + '-le-ssl')
73
+ end
74
+
75
+ def write_available_no_ssl_site
76
+ infom 'Writing no SSL site conf...'
77
+ no_ssl_site.write(no_ssl_site_content)
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
5
+
6
+ module Avm
7
+ module Stereotypes
8
+ module EacUbuntuBase0
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/require_sub'
5
+ ::EacRubyUtils.require_sub(__FILE__)
6
+
7
+ module Avm
8
+ module Stereotypes
9
+ module EacUbuntuBase0
10
+ class Apache
11
+ common_constructor :host_env
12
+
13
+ def etc_root
14
+ '/etc/apache2'
15
+ end
16
+
17
+ def service(command)
18
+ host_env.command('sudo', 'service', 'apache2', command)
19
+ end
20
+
21
+ def site(name)
22
+ ::Avm::Stereotypes::EacUbuntuBase0::Apache::Site.new(self, name)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module Stereotypes
7
+ module EacUbuntuBase0
8
+ class Apache
9
+ class Site
10
+ common_constructor :apache, :name
11
+
12
+ def available_path
13
+ ::File.join(apache.etc_root, 'sites-available', "#{name}.conf")
14
+ end
15
+
16
+ def available?
17
+ apache.host_env.file(available_path).exist?
18
+ end
19
+
20
+ def disable
21
+ apache.host_env.command('sudo', 'a2dissite', name).execute!
22
+ end
23
+
24
+ def enable
25
+ apache.host_env.command('sudo', 'a2ensite', name).execute!
26
+ end
27
+
28
+ def enabled_path
29
+ ::File.join(apache.etc_root, 'sites-enabled', "#{name}.conf")
30
+ end
31
+
32
+ def enabled?
33
+ apache.host_env.file(enabled_path).exist?
34
+ end
35
+
36
+ def remove
37
+ remove_disabled
38
+ remove_available
39
+ end
40
+
41
+ def remove_available
42
+ raise 'Remove enabled before' if enabled?
43
+
44
+ apache.host_env.command('sudo', 'rm', '-f', available_path).execute! if available?
45
+ end
46
+
47
+ def remove_disabled
48
+ disable if enabled?
49
+ apache.host_env.command('sudo', 'rm', '-f', enabled_path).execute! if enabled?
50
+ end
51
+
52
+ def write(content)
53
+ ::EacRubyUtils::Envs.local.command('echo', content).pipe(
54
+ apache.host_env.command('sudo', 'tee', available_path)
55
+ ).execute!
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_ruby_utils/console/speaker'
5
+ require 'avm/stereotypes/eac_rails_base0/apache_host'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class EacRailsBase0 < ::EacRubyUtils::Console::DocoptRunner
11
+ class ApacheHost < ::EacRubyUtils::Console::DocoptRunner
12
+ include ::EacRubyUtils::Console::Speaker
13
+
14
+ DOC = <<~DOCOPT
15
+ Deploy for EacRailsBase0 instance.
16
+
17
+ Usage:
18
+ __PROGRAM__ [options]
19
+ __PROGRAM__ -h | --help
20
+
21
+ Options:
22
+ -h --help Show this screen.
23
+ -r --reference=<git-reference> Git reference to deploy.
24
+ DOCOPT
25
+
26
+ def run
27
+ result = ::Avm::Stereotypes::EacRailsBase0::ApacheHost.new(
28
+ context(:instance)
29
+ ).run
30
+ if result.error?
31
+ fatal_error result.to_s
32
+ else
33
+ infov 'Result', result.label
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.19.0'
5
+ VERSION = '0.20.0'
6
6
  end
7
7
  end
@@ -0,0 +1,11 @@
1
+ <VirtualHost *:80>
2
+ ServerName "%%WEB.HOSTNAME%%"
3
+ DocumentRoot "%%FS_PATH%%/public"
4
+ PassengerEnabled On
5
+
6
+ <Directory "%%FS_PATH%%/public">
7
+ Allow from all
8
+ Options -MultiViews
9
+ Require all granted
10
+ </Directory>
11
+ </VirtualHost>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
@@ -204,9 +204,11 @@ files:
204
204
  - lib/avm/instances/base.rb
205
205
  - lib/avm/instances/base/auto_values.rb
206
206
  - lib/avm/instances/base/auto_values/access.rb
207
+ - lib/avm/instances/base/auto_values/admin.rb
207
208
  - lib/avm/instances/base/auto_values/database.rb
208
209
  - lib/avm/instances/base/auto_values/filesystem.rb
209
210
  - lib/avm/instances/base/auto_values/source.rb
211
+ - lib/avm/instances/base/auto_values/web.rb
210
212
  - lib/avm/instances/entries.rb
211
213
  - lib/avm/instances/entries/entry_reader.rb
212
214
  - lib/avm/patches.rb
@@ -215,8 +217,12 @@ files:
215
217
  - lib/avm/result.rb
216
218
  - lib/avm/stereotypes.rb
217
219
  - lib/avm/stereotypes/eac_rails_base0.rb
220
+ - lib/avm/stereotypes/eac_rails_base0/apache_host.rb
218
221
  - lib/avm/stereotypes/eac_rails_base0/deploy.rb
219
222
  - lib/avm/stereotypes/eac_rails_base0/instance.rb
223
+ - lib/avm/stereotypes/eac_ubuntu_base0.rb
224
+ - lib/avm/stereotypes/eac_ubuntu_base0/apache.rb
225
+ - lib/avm/stereotypes/eac_ubuntu_base0/apache/site.rb
220
226
  - lib/avm/stereotypes/eac_webapp_base0.rb
221
227
  - lib/avm/stereotypes/eac_webapp_base0/deploy.rb
222
228
  - lib/avm/stereotypes/eac_webapp_base0/instance.rb
@@ -233,6 +239,7 @@ files:
233
239
  - lib/avm/tools/git.rb
234
240
  - lib/avm/tools/runner.rb
235
241
  - lib/avm/tools/runner/eac_rails_base0.rb
242
+ - lib/avm/tools/runner/eac_rails_base0/apache_host.rb
236
243
  - lib/avm/tools/runner/eac_rails_base0/deploy.rb
237
244
  - lib/avm/tools/runner/eac_wordpress_base0.rb
238
245
  - lib/avm/tools/runner/eac_wordpress_base0/data.rb
@@ -249,6 +256,7 @@ files:
249
256
  - lib/avm/tools/runner/git/issue.rb
250
257
  - lib/avm/tools/runner/git/issue/complete.rb
251
258
  - lib/avm/tools/version.rb
259
+ - template/avm/stereotypes/eac_rails_base0/apache_host/no_ssl.conf
252
260
  - template/avm/stereotypes/eac_rails_base0/deploy/config/database.yml.template
253
261
  - template/avm/stereotypes/eac_wordpress_base0/deploy/wp-config.php.template
254
262
  homepage: