avm-tools 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/instances/base/auto_values.rb +1 -1
- data/lib/avm/instances/base/auto_values/database.rb +2 -2
- data/lib/avm/instances/base/auto_values/system.rb +23 -0
- data/lib/avm/stereotypes/eac_rails_base0/apache_host.rb +6 -69
- data/lib/avm/stereotypes/eac_webapp_base0/apache_host.rb +98 -0
- data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +27 -0
- data/lib/avm/tools/runner/eac_rails_base0/apache_host.rb +0 -1
- data/lib/avm/tools/runner/eac_wordpress_base0.rb +1 -0
- data/lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb +39 -0
- data/lib/avm/tools/version.rb +1 -1
- data/template/avm/stereotypes/{eac_rails_base0 → eac_webapp_base0}/apache_host/no_ssl.conf +3 -3
- data/template/avm/stereotypes/eac_wordpress_base0/deploy/wp-config.php.template +3 -3
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8706b02e9000a68816108236851b8d1d80f23c4e4459e080512465c5380bdd75
|
4
|
+
data.tar.gz: 663eb3ef35a98308fcecb64f6a1158165b83f69ffcfeea8a37d15d1710b27bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ea0def902b2667c4dcb99be2221c917d12ac0acbe534035fe1d296afd4ad4f90ba1a722a1a1e2759b34a2b69791c54615623279813fe410acf2f748fb806b46
|
7
|
+
data.tar.gz: dac7b5102c6624d928f18003e3b745b7fbd89aad73e8b721eedbb08470486f0b4724479cc2d74eaa46e507ee6cd0c17da32c0a38df6afeeb21dcc11667347a8b
|
@@ -10,7 +10,7 @@ module Avm
|
|
10
10
|
extend ::ActiveSupport::Concern
|
11
11
|
|
12
12
|
included do
|
13
|
-
%w[Access Admin Database Filesystem Source Web].each do |class_name|
|
13
|
+
%w[Access Admin Database Filesystem Source System Web].each do |class_name|
|
14
14
|
include const_get(class_name)
|
15
15
|
end
|
16
16
|
end
|
@@ -15,7 +15,7 @@ module Avm
|
|
15
15
|
DEFAULT_SYSTEM = 'postgresql'
|
16
16
|
|
17
17
|
def auto_database_name
|
18
|
-
inherited_entry_value(:
|
18
|
+
inherited_entry_value(:'database.id', 'database.name') || id
|
19
19
|
end
|
20
20
|
|
21
21
|
def auto_database_hostname
|
@@ -41,7 +41,7 @@ module Avm
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def database_auto_common(suffix)
|
44
|
-
inherited_entry_value(
|
44
|
+
inherited_entry_value('database.id', "database.#{suffix}") ||
|
45
45
|
inherited_entry_value(:host_id, "database.#{suffix}")
|
46
46
|
end
|
47
47
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'addressable'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Instances
|
7
|
+
class Base
|
8
|
+
module AutoValues
|
9
|
+
module System
|
10
|
+
def auto_system_username
|
11
|
+
inherited_entry_value(:host_id, 'system.username') ||
|
12
|
+
read_entry_optional('ssh.username')
|
13
|
+
end
|
14
|
+
|
15
|
+
def auto_system_groupname
|
16
|
+
inherited_entry_value(:host_id, 'system.groupname') ||
|
17
|
+
read_entry_optional('system.username')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,80 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'avm/stereotypes/eac_ubuntu_base0/apache'
|
5
|
-
require 'avm/templates/file'
|
3
|
+
require 'avm/stereotypes/eac_webapp_base0/apache_host'
|
6
4
|
|
7
5
|
module Avm
|
8
6
|
module Stereotypes
|
9
7
|
module EacRailsBase0
|
10
|
-
class ApacheHost
|
11
|
-
|
12
|
-
|
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')
|
8
|
+
class ApacheHost < ::Avm::Stereotypes::EacWebappBase0::ApacheHost
|
9
|
+
def document_root
|
10
|
+
"#{instance.read_entry(:fs_path)}/public"
|
73
11
|
end
|
74
12
|
|
75
|
-
def
|
76
|
-
|
77
|
-
no_ssl_site.write(no_ssl_site_content)
|
13
|
+
def extra_content
|
14
|
+
'PassengerEnabled On'
|
78
15
|
end
|
79
16
|
end
|
80
17
|
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/core_ext'
|
4
|
+
require 'avm/patches/object/template'
|
5
|
+
require 'avm/stereotypes/eac_ubuntu_base0/apache'
|
6
|
+
require 'avm/templates/file'
|
7
|
+
|
8
|
+
module Avm
|
9
|
+
module Stereotypes
|
10
|
+
module EacWebappBase0
|
11
|
+
class ApacheHost
|
12
|
+
enable_console_speaker
|
13
|
+
enable_simple_cache
|
14
|
+
common_constructor :instance
|
15
|
+
|
16
|
+
def run
|
17
|
+
write_available_no_ssl_site
|
18
|
+
enable_no_ssl_site
|
19
|
+
remove_ssl_site
|
20
|
+
reload_apache
|
21
|
+
run_certbot
|
22
|
+
enable_ssl_site
|
23
|
+
reload_apache
|
24
|
+
::Avm::Result.success('Done')
|
25
|
+
end
|
26
|
+
|
27
|
+
def no_ssl_site_content
|
28
|
+
::Avm::Templates::File.new(
|
29
|
+
::File.join(::Avm::Stereotypes::EacWebappBase0::ApacheHost.template_path, 'no_ssl.conf')
|
30
|
+
).apply(EntriesReader.new(self, instance))
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def apache_uncached
|
36
|
+
::Avm::Stereotypes::EacUbuntuBase0::Apache.new(instance.host_env)
|
37
|
+
end
|
38
|
+
|
39
|
+
def enable_no_ssl_site
|
40
|
+
infom 'Enabling no SSL site...'
|
41
|
+
no_ssl_site.enable
|
42
|
+
end
|
43
|
+
|
44
|
+
def enable_ssl_site
|
45
|
+
infom 'Enabling SSL site...'
|
46
|
+
ssl_site.enable
|
47
|
+
end
|
48
|
+
|
49
|
+
def no_ssl_site_uncached
|
50
|
+
apache.site(instance.id)
|
51
|
+
end
|
52
|
+
|
53
|
+
def reload_apache
|
54
|
+
infom 'Reloading Apache...'
|
55
|
+
apache.service('reload')
|
56
|
+
end
|
57
|
+
|
58
|
+
def remove_ssl_site
|
59
|
+
infom 'Removing SSL site...'
|
60
|
+
ssl_site.remove
|
61
|
+
end
|
62
|
+
|
63
|
+
def run_certbot
|
64
|
+
infom 'Running Certbot...'
|
65
|
+
instance.host_env.command(
|
66
|
+
'sudo', 'certbot', '--apache', '--domain', instance.read_entry('web.hostname'),
|
67
|
+
'--redirect', '--non-interactive', '--agree-tos',
|
68
|
+
'--email', instance.read_entry('admin.email')
|
69
|
+
).system!
|
70
|
+
end
|
71
|
+
|
72
|
+
def ssl_site_uncached
|
73
|
+
apache.site(no_ssl_site.name + '-le-ssl')
|
74
|
+
end
|
75
|
+
|
76
|
+
def write_available_no_ssl_site
|
77
|
+
infom 'Writing no SSL site conf...'
|
78
|
+
no_ssl_site.write(no_ssl_site_content)
|
79
|
+
end
|
80
|
+
|
81
|
+
class EntriesReader
|
82
|
+
common_constructor :job, :instance
|
83
|
+
|
84
|
+
def read_entry(path, options = {})
|
85
|
+
entry_from_job(path) || instance.read_entry(path, options)
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
|
90
|
+
def entry_from_job(path)
|
91
|
+
method = path.gsub('.', '_').underscore
|
92
|
+
return job.send(method) if job.respond_to?(method, true)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'avm/stereotypes/eac_webapp_base0/apache_host'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module Stereotypes
|
7
|
+
module EacWordpressBase0
|
8
|
+
class ApacheHost < ::Avm::Stereotypes::EacWebappBase0::ApacheHost
|
9
|
+
def document_root
|
10
|
+
instance.read_entry(:fs_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def extra_content
|
14
|
+
"AssignUserID #{system_user} #{system_group}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def system_user
|
18
|
+
instance.read_entry('system.username')
|
19
|
+
end
|
20
|
+
|
21
|
+
def system_group
|
22
|
+
instance.read_entry('system.groupname')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'eac_ruby_utils/console/docopt_runner'
|
4
4
|
require 'eac_ruby_utils/simple_cache'
|
5
5
|
require 'avm/stereotypes/eac_wordpress_base0/instance'
|
6
|
+
require 'avm/tools/runner/eac_wordpress_base0/apache_host'
|
6
7
|
require 'avm/tools/runner/eac_wordpress_base0/data'
|
7
8
|
require 'avm/tools/runner/eac_wordpress_base0/deploy'
|
8
9
|
|
@@ -0,0 +1,39 @@
|
|
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_wordpress_base0/apache_host'
|
6
|
+
|
7
|
+
module Avm
|
8
|
+
module Tools
|
9
|
+
class Runner < ::EacRubyUtils::Console::DocoptRunner
|
10
|
+
class EacWordpressBase0 < ::EacRubyUtils::Console::DocoptRunner
|
11
|
+
class ApacheHost < ::EacRubyUtils::Console::DocoptRunner
|
12
|
+
include ::EacRubyUtils::Console::Speaker
|
13
|
+
|
14
|
+
DOC = <<~DOCOPT
|
15
|
+
Configure Apache virtual host for EacWordpressBase0 instance.
|
16
|
+
|
17
|
+
Usage:
|
18
|
+
__PROGRAM__ [options]
|
19
|
+
__PROGRAM__ -h | --help
|
20
|
+
|
21
|
+
Options:
|
22
|
+
-h --help Show this screen.
|
23
|
+
DOCOPT
|
24
|
+
|
25
|
+
def run
|
26
|
+
result = ::Avm::Stereotypes::EacWordpressBase0::ApacheHost.new(
|
27
|
+
context(:instance)
|
28
|
+
).run
|
29
|
+
if result.error?
|
30
|
+
fatal_error result.to_s
|
31
|
+
else
|
32
|
+
infov 'Result', result.label
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/avm/tools/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
<VirtualHost *:80>
|
2
2
|
ServerName "%%WEB.HOSTNAME%%"
|
3
|
-
DocumentRoot "%%
|
4
|
-
|
3
|
+
DocumentRoot "%%DOCUMENT_ROOT%%"
|
4
|
+
%%EXTRA_CONTENT%%
|
5
5
|
|
6
|
-
<Directory "%%
|
6
|
+
<Directory "%%DOCUMENT_ROOT%%">
|
7
7
|
Allow from all
|
8
8
|
Options -MultiViews
|
9
9
|
Require all granted
|
@@ -20,13 +20,13 @@
|
|
20
20
|
|
21
21
|
// ** MySQL settings - You can get this info from your web host ** //
|
22
22
|
/** The name of the database for WordPress */
|
23
|
-
define( 'DB_NAME', '%%
|
23
|
+
define( 'DB_NAME', '%%DATABASE.NAME%%' );
|
24
24
|
|
25
25
|
/** MySQL database username */
|
26
|
-
define( 'DB_USER', '%%
|
26
|
+
define( 'DB_USER', '%%DATABASE.USER%%' );
|
27
27
|
|
28
28
|
/** MySQL database password */
|
29
|
-
define( 'DB_PASSWORD', '%%
|
29
|
+
define( 'DB_PASSWORD', '%%DATABASE.PASSWORD%%' );
|
30
30
|
|
31
31
|
/** MySQL hostname */
|
32
32
|
define( 'DB_HOST', 'localhost' );
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avm-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha-parsers
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/avm/instances/base/auto_values/database.rb
|
209
209
|
- lib/avm/instances/base/auto_values/filesystem.rb
|
210
210
|
- lib/avm/instances/base/auto_values/source.rb
|
211
|
+
- lib/avm/instances/base/auto_values/system.rb
|
211
212
|
- lib/avm/instances/base/auto_values/web.rb
|
212
213
|
- lib/avm/instances/entries.rb
|
213
214
|
- lib/avm/instances/entries/entry_reader.rb
|
@@ -224,8 +225,10 @@ files:
|
|
224
225
|
- lib/avm/stereotypes/eac_ubuntu_base0/apache.rb
|
225
226
|
- lib/avm/stereotypes/eac_ubuntu_base0/apache/site.rb
|
226
227
|
- lib/avm/stereotypes/eac_webapp_base0.rb
|
228
|
+
- lib/avm/stereotypes/eac_webapp_base0/apache_host.rb
|
227
229
|
- lib/avm/stereotypes/eac_webapp_base0/deploy.rb
|
228
230
|
- lib/avm/stereotypes/eac_webapp_base0/instance.rb
|
231
|
+
- lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb
|
229
232
|
- lib/avm/stereotypes/eac_wordpress_base0/deploy.rb
|
230
233
|
- lib/avm/stereotypes/eac_wordpress_base0/instance.rb
|
231
234
|
- lib/avm/stereotypes/postgresql.rb
|
@@ -242,6 +245,7 @@ files:
|
|
242
245
|
- lib/avm/tools/runner/eac_rails_base0/apache_host.rb
|
243
246
|
- lib/avm/tools/runner/eac_rails_base0/deploy.rb
|
244
247
|
- lib/avm/tools/runner/eac_wordpress_base0.rb
|
248
|
+
- lib/avm/tools/runner/eac_wordpress_base0/apache_host.rb
|
245
249
|
- lib/avm/tools/runner/eac_wordpress_base0/data.rb
|
246
250
|
- lib/avm/tools/runner/eac_wordpress_base0/data/dump.rb
|
247
251
|
- lib/avm/tools/runner/eac_wordpress_base0/data/load.rb
|
@@ -256,8 +260,8 @@ files:
|
|
256
260
|
- lib/avm/tools/runner/git/issue.rb
|
257
261
|
- lib/avm/tools/runner/git/issue/complete.rb
|
258
262
|
- lib/avm/tools/version.rb
|
259
|
-
- template/avm/stereotypes/eac_rails_base0/apache_host/no_ssl.conf
|
260
263
|
- template/avm/stereotypes/eac_rails_base0/deploy/config/database.yml.template
|
264
|
+
- template/avm/stereotypes/eac_webapp_base0/apache_host/no_ssl.conf
|
261
265
|
- template/avm/stereotypes/eac_wordpress_base0/deploy/wp-config.php.template
|
262
266
|
homepage:
|
263
267
|
licenses: []
|