avm-tools 0.69.3 → 0.72.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/lib/avm/data/instance/files_unit.rb +2 -1
  3. data/lib/avm/eac_rails_base0/apache_host.rb +1 -1
  4. data/lib/avm/eac_rails_base0/apache_path.rb +50 -0
  5. data/lib/avm/eac_rails_base0/deploy.rb +2 -1
  6. data/lib/avm/eac_rails_base0/instance.rb +2 -2
  7. data/lib/avm/eac_redmine_base0/deploy.rb +2 -2
  8. data/lib/avm/eac_redmine_base0/instance.rb +6 -5
  9. data/lib/avm/eac_ubuntu_base0/apache.rb +26 -0
  10. data/lib/avm/eac_ubuntu_base0/apache/resource.rb +59 -0
  11. data/lib/avm/eac_ubuntu_base0/docker_image.rb +14 -0
  12. data/lib/avm/eac_webapp_base0/apache_host.rb +2 -2
  13. data/lib/avm/eac_webapp_base0/deploy.rb +2 -2
  14. data/lib/avm/eac_webapp_base0/deploy/file_unit.rb +2 -1
  15. data/lib/avm/git/auto_commit_path.rb +4 -2
  16. data/lib/avm/instances/application.rb +4 -0
  17. data/lib/avm/instances/base.rb +2 -1
  18. data/lib/avm/instances/base/auto_values/access.rb +5 -4
  19. data/lib/avm/instances/base/auto_values/admin.rb +2 -2
  20. data/lib/avm/instances/base/auto_values/database.rb +1 -1
  21. data/lib/avm/instances/base/auto_values/filesystem.rb +8 -2
  22. data/lib/avm/instances/base/auto_values/ruby.rb +1 -1
  23. data/lib/avm/instances/base/auto_values/system.rb +2 -2
  24. data/lib/avm/instances/entries.rb +5 -8
  25. data/lib/avm/instances/entry.rb +53 -0
  26. data/lib/avm/instances/entry_keys.rb +39 -6
  27. data/lib/avm/patches/i18n.rb +1 -1
  28. data/lib/avm/patches/object/template.rb +1 -1
  29. data/lib/avm/rails/instance.rb +19 -0
  30. data/lib/avm/self.rb +0 -4
  31. data/lib/avm/self/instance.rb +1 -1
  32. data/lib/avm/self/root.rb +13 -0
  33. data/lib/avm/stereotypes/eac_wordpress_base0/apache_host.rb +1 -1
  34. data/lib/avm/tools/runner/eac_rails_base0.rb +7 -12
  35. data/lib/avm/tools/runner/eac_rails_base0/apache_path.rb +38 -0
  36. data/lib/avm/tools/runner/eac_rails_base0/rails_server.rb +41 -0
  37. data/lib/avm/tools/runner/git/deploy.rb +3 -1
  38. data/lib/avm/tools/runner/instance.rb +28 -0
  39. data/lib/avm/tools/runner/instance/info.rb +44 -0
  40. data/lib/avm/tools/version.rb +1 -1
  41. data/template/avm/eac_rails_base0/apache_path/default.conf +13 -0
  42. data/vendor/eac_cli/lib/eac_cli/runner.rb +1 -1
  43. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +19 -2
  44. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  45. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb +2 -1
  46. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb +1 -1
  47. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/multiple/decorated_gem.rb +10 -6
  48. data/vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/version.rb +1 -1
  49. data/vendor/eac_ruby_gems_utils/spec/{rubocop_check_spec.rb → code/rubocop_check_spec.rb} +0 -0
  50. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/ruby/command.rb +2 -1
  51. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  52. metadata +15 -8
  53. data/lib/avm/instances/entries/entry_reader.rb +0 -45
  54. data/lib/avm/stereotypes/eac_ubuntu_base0/apache.rb +0 -27
  55. data/lib/avm/stereotypes/eac_ubuntu_base0/apache/site.rb +0 -61
  56. data/lib/avm/stereotypes/eac_ubuntu_base0/docker_image.rb +0 -16
  57. data/lib/avm/stereotypes/rails/instance.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83ba40f1bd12e44664ec4bd6824bc269eb6a5012f51fdb7fdf38f90194f084d8
4
- data.tar.gz: 872cf085c7de0dda3da9104b28b8a48ac100473ae902d4596e89295ee808b40b
3
+ metadata.gz: acf6e22d7179f5a2ad489b5091ef57883c91d94020815952bc3135df2f1cfd7d
4
+ data.tar.gz: 4f4eb1ef234e44157bc7b66dc44b2903e2c881e3406f31ee6a183eebba3f2ec0
5
5
  SHA512:
6
- metadata.gz: 3654fc45fe954c2a3caaa7d9d0d6bfc2ad883d0e2f93cb85fe798f0e12785eeb1f2da2c72cc0921e514a48c9942f2a05cf2afc0788faa6e574af3af78195bf22
7
- data.tar.gz: f14791c5d6f811644243763d6e2e3d6dfb0c6812dd1d55f2e7d96afc65ac16aea399178cb9fe335a047808e7a34a457741f5eda4598e196237d44e02a4bf133b
6
+ metadata.gz: c0fbaaa584f10fc580e2f6c1c2635b673b9f481603b00a5851c2894955cc930d748111d3eb15a5e7069d0f35ac93fe6da7e1519e757822e03641eae989bf08f3
7
+ data.tar.gz: 8040458407704e5d6541556dfc03929ff6cf753e7e1fec83ac835602faac08327fece6b7e684cf58f80ddf1938d8ade8059fd2f6343f78010ca437228947e4e0
@@ -18,7 +18,7 @@ module Avm
18
18
  before_load :clear_files
19
19
 
20
20
  def files_path
21
- ::File.join(instance.read_entry(:fs_path), fs_path_subpath)
21
+ ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH), fs_path_subpath)
22
22
  end
23
23
 
24
24
  def dump_command
@@ -31,6 +31,7 @@ module Avm
31
31
 
32
32
  def clear_files
33
33
  infom "Removing all files under #{files_path}..."
34
+ instance.host_env.command('mkdir', '-p', files_path).execute!
34
35
  instance.host_env.command('find', files_path, '-mindepth', 1, '-delete').execute!
35
36
  end
36
37
  end
@@ -6,7 +6,7 @@ module Avm
6
6
  module EacRailsBase0
7
7
  class ApacheHost < ::Avm::EacWebappBase0::ApacheHost
8
8
  def document_root
9
- "#{instance.read_entry(:fs_path)}/public"
9
+ "#{instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)}/public"
10
10
  end
11
11
 
12
12
  def extra_content
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ubuntu_base0/apache'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRailsBase0
8
+ class ApachePath
9
+ enable_console_speaker
10
+ enable_simple_cache
11
+ common_constructor :instance, :options, default: [{}]
12
+
13
+ def run
14
+ write_available_conf
15
+ enable_conf
16
+ reload_apache
17
+ ::Avm::Result.success('Done')
18
+ end
19
+
20
+ def content
21
+ template.child('default.conf').apply(instance)
22
+ end
23
+
24
+ private
25
+
26
+ def apache_uncached
27
+ ::Avm::EacUbuntuBase0::Apache.new(instance.host_env)
28
+ end
29
+
30
+ def enable_conf
31
+ infom 'Enabling configuration...'
32
+ conf.enable
33
+ end
34
+
35
+ def reload_apache
36
+ infom 'Reloading Apache...'
37
+ apache.service('reload')
38
+ end
39
+
40
+ def conf_uncached
41
+ apache.conf(instance.id)
42
+ end
43
+
44
+ def write_available_conf
45
+ infom 'Writing available configuration...'
46
+ conf.write(content)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -42,7 +42,8 @@ module Avm
42
42
  def touch_restart_file
43
43
  infom 'Touching restart file...'
44
44
  instance.host_env.command(
45
- 'touch', ::File.join(instance.read_entry(:fs_path), 'tmp', 'restart.txt')
45
+ 'touch', ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH),
46
+ 'tmp', 'restart.txt')
46
47
  ).system!
47
48
  end
48
49
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_webapp_base0/instance'
4
- require 'avm/stereotypes/rails/instance'
4
+ require 'avm/rails/instance'
5
5
 
6
6
  module Avm
7
7
  module EacRailsBase0
8
8
  class Instance < ::Avm::EacWebappBase0::Instance
9
- include ::Avm::Stereotypes::Rails::Instance
9
+ include ::Avm::Rails::Instance
10
10
 
11
11
  FILES_UNITS = { uploads: 'public/uploads' }.freeze
12
12
  end
@@ -20,8 +20,8 @@ module Avm
20
20
  end
21
21
 
22
22
  def installer_path
23
- ::File.join(instance.read_entry(:fs_path), 'plugins', 'redmine_installer', 'installer',
24
- 'run.sh')
23
+ ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH), 'plugins',
24
+ 'redmine_installer', 'installer', 'run.sh')
25
25
  end
26
26
 
27
27
  def install_task
@@ -1,24 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/eac_redmine_base0/data_unit'
4
- require 'avm/stereotypes/eac_ubuntu_base0/docker_image'
4
+ require 'avm/eac_ubuntu_base0/docker_image'
5
5
  require 'avm/eac_webapp_base0/instance'
6
- require 'avm/stereotypes/rails/instance'
6
+ require 'avm/rails/instance'
7
7
 
8
8
  module Avm
9
9
  module EacRedmineBase0
10
10
  class Instance < ::Avm::EacWebappBase0::Instance
11
- include ::Avm::Stereotypes::Rails::Instance
11
+ include ::Avm::Rails::Instance
12
12
 
13
13
  FILES_UNITS = { files: 'files' }.freeze
14
14
 
15
15
  def docker_image_class
16
- ::Avm::Stereotypes::EacUbuntuBase0::DockerImage
16
+ ::Avm::EacUbuntuBase0::DockerImage
17
17
  end
18
18
 
19
19
  def docker_run_arguments
20
20
  [
21
- '--volume', "#{read_entry(:fs_path)}:/home/myuser/eac_redmine_base0",
21
+ '--volume',
22
+ "#{read_entry(::Avm::Instances::EntryKeys::FS_PATH)}:/home/myuser/eac_redmine_base0",
22
23
  '--publish', "#{read_entry(:ssh_port)}:22",
23
24
  '--publish', "#{read_entry(:http_port)}:80",
24
25
  '--publish', "#{read_entry(:https_port)}:443"
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacUbuntuBase0
7
+ class Apache
8
+ require_sub __FILE__
9
+ common_constructor :host_env
10
+
11
+ def etc_root
12
+ '/etc/apache2'
13
+ end
14
+
15
+ def service(command)
16
+ host_env.command('sudo', 'service', 'apache2', command)
17
+ end
18
+
19
+ { conf: :conf, site: :sites }.each do |type, directory_prefix|
20
+ define_method type do |name|
21
+ ::Avm::EacUbuntuBase0::Apache::Resource.new(self, type, directory_prefix, name)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacUbuntuBase0
7
+ class Apache
8
+ class Resource
9
+ common_constructor :apache, :type, :directory_prefix, :name
10
+
11
+ def available_path
12
+ ::File.join(apache.etc_root, "#{directory_prefix}-available", "#{name}.conf")
13
+ end
14
+
15
+ def available?
16
+ apache.host_env.file(available_path).exist?
17
+ end
18
+
19
+ def disable
20
+ apache.host_env.command('sudo', "a2dis#{type}", name).execute!
21
+ end
22
+
23
+ def enable
24
+ apache.host_env.command('sudo', "a2en#{type}", name).execute!
25
+ end
26
+
27
+ def enabled_path
28
+ ::File.join(apache.etc_root, "#{directory_prefix}-enabled", "#{name}.conf")
29
+ end
30
+
31
+ def enabled?
32
+ apache.host_env.file(enabled_path).exist?
33
+ end
34
+
35
+ def remove
36
+ remove_disabled
37
+ remove_available
38
+ end
39
+
40
+ def remove_available
41
+ raise 'Remove enabled before' if enabled?
42
+
43
+ apache.host_env.command('sudo', 'rm', '-f', available_path).execute! if available?
44
+ end
45
+
46
+ def remove_disabled
47
+ disable if enabled?
48
+ apache.host_env.command('sudo', 'rm', '-f', enabled_path).execute! if enabled?
49
+ end
50
+
51
+ def write(content)
52
+ ::EacRubyUtils::Envs.local.command('echo', content).pipe(
53
+ apache.host_env.command('sudo', 'tee', available_path)
54
+ ).execute!
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/docker/image'
5
+
6
+ module Avm
7
+ module EacUbuntuBase0
8
+ class DockerImage < ::Avm::Docker::Image
9
+ def stereotype_tag
10
+ 'eac_ubuntu_base0'
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'eac_ruby_utils/core_ext'
4
4
  require 'avm/patches/object/template'
5
- require 'avm/stereotypes/eac_ubuntu_base0/apache'
5
+ require 'avm/eac_ubuntu_base0/apache'
6
6
  require 'avm/patches/object/template'
7
7
 
8
8
  module Avm
@@ -35,7 +35,7 @@ module Avm
35
35
  private
36
36
 
37
37
  def apache_uncached
38
- ::Avm::Stereotypes::EacUbuntuBase0::Apache.new(instance.host_env)
38
+ ::Avm::EacUbuntuBase0::Apache.new(instance.host_env)
39
39
  end
40
40
 
41
41
  def enable_no_ssl_site
@@ -32,7 +32,7 @@ module Avm
32
32
  def build_git_commit
33
33
  ::Avm::Git::Commit.new(git, commit_sha1).deploy_to_env_path(
34
34
  instance.host_env,
35
- instance.read_entry(:fs_path)
35
+ instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
36
36
  ).variables_source_set(instance)
37
37
  end
38
38
 
@@ -95,7 +95,7 @@ module Avm
95
95
  end
96
96
 
97
97
  def git_repository_path
98
- instance.source_instance.read_entry(:fs_path)
98
+ instance.source_instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH)
99
99
  end
100
100
  end
101
101
  end
@@ -27,7 +27,8 @@ module Avm
27
27
  end
28
28
 
29
29
  def target_path
30
- ::File.join(instance.read_entry(:fs_path), fs_path_subpath.to_s)
30
+ ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH),
31
+ fs_path_subpath.to_s)
31
32
  end
32
33
 
33
34
  def link_source_target
@@ -6,9 +6,11 @@ module Avm
6
6
  module Git
7
7
  class AutoCommitPath
8
8
  enable_console_speaker
9
- common_constructor :git, :path
9
+ common_constructor :git, :path do
10
+ self.path = path.to_pathname
11
+ end
10
12
 
11
- CLASS_NAME_PATTERNS = [%r{lib/(.+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
13
+ CLASS_NAME_PATTERNS = [%r{lib/((?!.*/lib/).+)\.rb\z}, %r{app/[^/]+/(.+)\.rb\z}].freeze
12
14
 
13
15
  def run
14
16
  banner
@@ -13,6 +13,10 @@ module Avm
13
13
  @id = id.to_s
14
14
  end
15
15
 
16
+ def to_s
17
+ id
18
+ end
19
+
16
20
  def instance(suffix)
17
21
  ::Avm::Instances::Base.new(self, suffix)
18
22
  end
@@ -3,6 +3,7 @@
3
3
  require 'eac_ruby_utils/require_sub'
4
4
  require 'eac_ruby_utils/simple_cache'
5
5
  require 'avm/instances/entries'
6
+ require 'avm/instances/entry_keys'
6
7
  ::EacRubyUtils.require_sub(__FILE__)
7
8
 
8
9
  module Avm
@@ -62,7 +63,7 @@ module Avm
62
63
  private
63
64
 
64
65
  def source_instance_uncached
65
- ::Avm::Instances::Base.by_id(read_entry(:source_instance_id))
66
+ ::Avm::Instances::Base.by_id(read_entry(::Avm::Instances::EntryKeys::SOURCE_INSTANCE_ID))
66
67
  end
67
68
  end
68
69
  end
@@ -10,19 +10,20 @@ module Avm
10
10
  end
11
11
 
12
12
  def auto_ssh_hostname
13
- inherited_entry_value(:host_id, 'ssh.hostname')
13
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.hostname')
14
14
  end
15
15
 
16
16
  def auto_ssh_port
17
- inherited_entry_value(:host_id, 'ssh.port') || 22
17
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.port') || 22
18
18
  end
19
19
 
20
20
  def auto_ssh_username
21
- inherited_entry_value(:host_id, 'ssh.username')
21
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.username')
22
22
  end
23
23
 
24
24
  def auto_ssh_url
25
- inherited_entry_value(:host_id, 'ssh.url') || auto_ssh_url_by_parts
25
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ssh.url') ||
26
+ auto_ssh_url_by_parts
26
27
  end
27
28
 
28
29
  def auto_ssh_url_by_parts
@@ -6,11 +6,11 @@ module Avm
6
6
  module AutoValues
7
7
  module Admin
8
8
  def auto_admin_email
9
- inherited_entry_value(:host_id, 'admin.email')
9
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'admin.email')
10
10
  end
11
11
 
12
12
  def auto_admin_name
13
- inherited_entry_value(:host_id, 'admin.name')
13
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'admin.name')
14
14
  end
15
15
  end
16
16
  end
@@ -46,7 +46,7 @@ module Avm
46
46
  def database_auto_common(suffix)
47
47
  database_key = ::Avm::Instances::EntryKeys.const_get("database_#{suffix}".upcase)
48
48
  inherited_entry_value(::Avm::Instances::EntryKeys::DATABASE_ID, database_key) ||
49
- inherited_entry_value(:host_id, database_key)
49
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, database_key)
50
50
  end
51
51
 
52
52
  def database_port_by_system
@@ -5,12 +5,18 @@ module Avm
5
5
  class Base
6
6
  module AutoValues
7
7
  module Filesystem
8
+ FS_PATH_KEY = :fs_path
9
+
8
10
  def auto_fs_path
9
- inherited_entry_value(:host_id, :fs_path) { |v| v + '/' + id }
11
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, FS_PATH_KEY) do |v|
12
+ v + '/' + id
13
+ end
10
14
  end
11
15
 
12
16
  def auto_data_fs_path
13
- inherited_entry_value(:host_id, :data_fs_path) { |v| v + '/' + id }
17
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, :data_fs_path) do |v|
18
+ v + '/' + id
19
+ end
14
20
  end
15
21
 
16
22
  def auto_fs_url
@@ -6,7 +6,7 @@ module Avm
6
6
  module AutoValues
7
7
  module Ruby
8
8
  def auto_ruby_version
9
- inherited_entry_value(:host_id, 'ruby.version')
9
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'ruby.version')
10
10
  end
11
11
  end
12
12
  end
@@ -8,12 +8,12 @@ module Avm
8
8
  module AutoValues
9
9
  module System
10
10
  def auto_system_username
11
- inherited_entry_value(:host_id, 'system.username') ||
11
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'system.username') ||
12
12
  read_entry_optional('ssh.username')
13
13
  end
14
14
 
15
15
  def auto_system_groupname
16
- inherited_entry_value(:host_id, 'system.groupname') ||
16
+ inherited_entry_value(::Avm::Instances::EntryKeys::HOST_ID, 'system.groupname') ||
17
17
  read_entry_optional('system.username')
18
18
  end
19
19
  end