specinfra 2.83.3 → 2.84.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
  SHA1:
3
- metadata.gz: 6705583dbf8312d537307218cb9c75cf28bbb9d6
4
- data.tar.gz: 2fe5613db13e84c37cbce47471cb273907f9cb6c
3
+ metadata.gz: 8409581baad2004ebb1c11e01d99598c39d5b5b4
4
+ data.tar.gz: b5febfb1b4f1130c379811b680669132ea5ea556
5
5
  SHA512:
6
- metadata.gz: 94f87c4bbbe61fc61e69d53a81f4b63273c056a9652ad3b86615f466c33c893608a7c7c5ef4df9fdd47747d2a6a5b913bb12d45b1a6c3cab08f8359c8e5ad698
7
- data.tar.gz: 9a28cb42d8c790052039a52b91cb13910addadb0881d8784525e1257ef8f4fe41ae17d2b03de1bbf66381fcac0cd681b3bd9ee85e5ac0cfa281d9cc272590307
6
+ metadata.gz: 9292019070312c7ce37faad96381f175be5c56f7ec733d2776ab265ed75ada52f6f6c859b06fbc564def43c0f7bfd7633fe0bc5ee41ece8dd2acb6c75e92fc12
7
+ data.tar.gz: d950653eb89b474c57b183a390e3d2f218915c8077b6da4ee592e32aeec83b031978cfa041365d51697fe27249f1db8121ac2e9c2fca86560bd680000e15166e
@@ -17,7 +17,7 @@ module Specinfra
17
17
  @base_image = get_or_pull_image(image)
18
18
 
19
19
  create_and_start_container
20
- ObjectSpace.define_finalizer(self, proc { cleanup_container })
20
+ ObjectSpace.define_finalizer(self, self.class.__send__(:finalizer_for, @container))
21
21
  elsif container = get_config(:docker_container)
22
22
  @container = ::Docker::Container.get(container)
23
23
  else
@@ -25,6 +25,25 @@ module Specinfra
25
25
  end
26
26
  end
27
27
 
28
+ class << self
29
+ protected
30
+
31
+ # Get a finalizer for given container.
32
+ #
33
+ # @param [::Docker::Container, nil] container
34
+ #
35
+ # @return [Proc]
36
+ def finalizer_for(container)
37
+ proc do
38
+ # noinspection RubyNilAnalysis
39
+ unless container.nil?
40
+ container.stop
41
+ container.delete
42
+ end
43
+ end
44
+ end
45
+ end
46
+
28
47
  def run_command(cmd, opts={})
29
48
  cmd = build_command(cmd)
30
49
  run_pre_command(opts)
@@ -77,8 +96,7 @@ module Specinfra
77
96
  end
78
97
 
79
98
  def cleanup_container
80
- @container.stop
81
- @container.delete
99
+ self.class.__send__(:finalizer_for, @container).call
82
100
  end
83
101
 
84
102
  def current_image
@@ -0,0 +1,31 @@
1
+ class Specinfra::Command::Amazon::V2022::Package < Specinfra::Command::Linux::Base::Package
2
+ class << self
3
+ def check_is_installed(package, version=nil)
4
+ cmd = "rpm -q #{escape(package)}"
5
+ if version
6
+ full_package = "#{package}-#{version}"
7
+ cmd = "#{cmd} | grep -w -- #{Regexp.escape(full_package)}"
8
+ end
9
+ cmd
10
+ end
11
+
12
+ alias :check_is_installed_by_rpm :check_is_installed
13
+
14
+ def get_version(package, opts=nil)
15
+ "rpm -q --qf '%{VERSION}-%{RELEASE}' #{package}"
16
+ end
17
+
18
+ def install(package, version=nil, option='')
19
+ if version
20
+ full_package = "#{package}-#{version}"
21
+ else
22
+ full_package = package
23
+ end
24
+ cmd = "dnf -y #{option} install #{escape(full_package)}"
25
+ end
26
+
27
+ def remove(package, option='')
28
+ "dnf -y #{option} remove #{package}"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ class Specinfra::Command::Amazon::V2022::Port < Specinfra::Command::Amazon::Base::Port
2
+ class << self
3
+ include Specinfra::Command::Module::Ss
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class Specinfra::Command::Amazon::V2022::Service < Specinfra::Command::Amazon::Base::Service
2
+ class << self
3
+ include Specinfra::Command::Module::Systemd
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ class Specinfra::Command::Amazon::V2022::Yumrepo < Specinfra::Command::Redhat::Base::Yumrepo
2
+ class << self
3
+ def check_exists(repository)
4
+ "dnf repolist all | grep -qsE \"^[\\!\\*]?#{escape(repository)}\(\\s\|$\|\\/)\""
5
+ end
6
+
7
+ def check_is_enabled(repository)
8
+ "dnf repolist enabled | grep -qs \"^[\\!\\*]\\?#{escape(repository)}\""
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ class Specinfra::Command::Amazon::V2022 < Specinfra::Command::Redhat::Base
2
+ end
@@ -127,6 +127,13 @@ require 'specinfra/command/amazon/v2'
127
127
  require 'specinfra/command/amazon/v2/service'
128
128
  require 'specinfra/command/amazon/v2/port'
129
129
 
130
+ # Amazon Linux V2022 (inherit RedHat)
131
+ require 'specinfra/command/amazon/v2022'
132
+ require 'specinfra/command/amazon/v2022/package'
133
+ require 'specinfra/command/amazon/v2022/port'
134
+ require 'specinfra/command/amazon/v2022/service'
135
+ require 'specinfra/command/amazon/v2022/yumrepo'
136
+
130
137
  # AIX (inherit Base)
131
138
  require 'specinfra/command/aix'
132
139
  require 'specinfra/command/aix/base'
@@ -1,3 +1,3 @@
1
1
  module Specinfra
2
- VERSION = "2.83.3"
2
+ VERSION = "2.84.0"
3
3
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'amazon', :release => '2022'
5
+
6
+ describe get_command(:check_package_is_installed, 'telnet') do
7
+ it { should eq 'rpm -q telnet' }
8
+ end
9
+
10
+ describe get_command(:check_package_is_installed, 'telnet', '0.17-48.el6.x86_64') do
11
+ it { should eq 'rpm -q telnet | grep -w -- telnet\\-0\\.17\\-48\\.el6\\.x86_64' }
12
+ end
13
+
14
+ describe get_command(:check_package_is_installed, 'linux-headers-$(uname -r)') do
15
+ it 'should be escaped (that is, command substitution should not work' do
16
+ should eq 'rpm -q linux-headers-\\$\\(uname\\ -r\\)'
17
+ end
18
+ end
19
+
20
+ describe get_command(:install_package, 'telnet') do
21
+ it { should eq "dnf -y install telnet" }
22
+ end
23
+
24
+ describe get_command(:install_package, 'telnet', '0.17-48.el6.x86_64') do
25
+ it { should eq "dnf -y install telnet-0.17-48.el6.x86_64" }
26
+ end
27
+
28
+ describe get_command(:install_package, 'linux-headers-$(uname -r)') do
29
+ it 'should be escaped (that is, command substitution should no work)' do
30
+ should eq "dnf -y install linux-headers-\\$\\(uname\\ -r\\)"
31
+ end
32
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'amazon', :release => '2022'
5
+
6
+ describe get_command(:check_port_is_listening, '80') do
7
+ it { should eq 'ss -tunl | grep -E -- :80\ ' }
8
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'amazon', :release => '2022'
5
+
6
+ describe get_command(:enable_service, 'httpd') do
7
+ it { should eq 'systemctl enable httpd' }
8
+ end
9
+
10
+ describe get_command(:disable_service, 'httpd') do
11
+ it { should eq 'systemctl disable httpd' }
12
+ end
13
+
14
+ describe get_command(:start_service, 'httpd') do
15
+ it { should eq 'systemctl start httpd' }
16
+ end
17
+
18
+ describe get_command(:stop_service, 'httpd') do
19
+ it { should eq 'systemctl stop httpd' }
20
+ end
21
+
22
+ describe get_command(:restart_service, 'httpd') do
23
+ it { should eq 'systemctl restart httpd' }
24
+ end
25
+
26
+ describe get_command(:reload_service, 'httpd') do
27
+ it { should eq 'systemctl reload httpd' }
28
+ end
29
+
30
+ describe get_command(:enable_service, 'sshd.socket') do
31
+ it { should eq 'systemctl enable sshd.socket' }
32
+ end
@@ -0,0 +1,12 @@
1
+ require 'spec_helper'
2
+
3
+ property[:os] = nil
4
+ set :os, :family => 'amazon', :release => '2022'
5
+
6
+ describe get_command(:check_yumrepo_exists, 'epel') do
7
+ it { should eq "dnf repolist all | grep -qsE \"^[\\!\\*]?epel\(\\s\|$\|\\/)\"" }
8
+ end
9
+
10
+ describe get_command(:check_yumrepo_is_enabled, 'epel') do
11
+ it { should eq "dnf repolist enabled | grep -qs \"^[\\!\\*]\\?epel\"" }
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: specinfra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.83.3
4
+ version: 2.84.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gosuke Miyashita
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-scp
@@ -170,6 +170,11 @@ files:
170
170
  - lib/specinfra/command/amazon/v2.rb
171
171
  - lib/specinfra/command/amazon/v2/port.rb
172
172
  - lib/specinfra/command/amazon/v2/service.rb
173
+ - lib/specinfra/command/amazon/v2022.rb
174
+ - lib/specinfra/command/amazon/v2022/package.rb
175
+ - lib/specinfra/command/amazon/v2022/port.rb
176
+ - lib/specinfra/command/amazon/v2022/service.rb
177
+ - lib/specinfra/command/amazon/v2022/yumrepo.rb
173
178
  - lib/specinfra/command/arch.rb
174
179
  - lib/specinfra/command/arch/base.rb
175
180
  - lib/specinfra/command/arch/base/package.rb
@@ -513,6 +518,10 @@ files:
513
518
  - spec/command/amazon/service_spec.rb
514
519
  - spec/command/amazon2/port_spec.rb
515
520
  - spec/command/amazon2/service_spec.rb
521
+ - spec/command/amazon2022/package_spec.rb
522
+ - spec/command/amazon2022/port_spec.rb
523
+ - spec/command/amazon2022/service_spec.rb
524
+ - spec/command/amazon2022/yumrepo_spec.rb
516
525
  - spec/command/base/file_spec.rb
517
526
  - spec/command/base/group_spec.rb
518
527
  - spec/command/base/host_spec.rb
@@ -656,6 +665,10 @@ test_files:
656
665
  - spec/command/amazon/service_spec.rb
657
666
  - spec/command/amazon2/port_spec.rb
658
667
  - spec/command/amazon2/service_spec.rb
668
+ - spec/command/amazon2022/package_spec.rb
669
+ - spec/command/amazon2022/port_spec.rb
670
+ - spec/command/amazon2022/service_spec.rb
671
+ - spec/command/amazon2022/yumrepo_spec.rb
659
672
  - spec/command/base/file_spec.rb
660
673
  - spec/command/base/group_spec.rb
661
674
  - spec/command/base/host_spec.rb