forked from mizzy/specinfra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mizzy#738 from shogo82148/support-amazonlinux2022
Support Amazon Linux 2022
- Loading branch information
Showing
10 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Specinfra::Command::Amazon::V2022 < Specinfra::Command::Redhat::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Specinfra::Command::Amazon::V2022::Package < Specinfra::Command::Linux::Base::Package | ||
class << self | ||
def check_is_installed(package, version=nil) | ||
cmd = "rpm -q #{escape(package)}" | ||
if version | ||
full_package = "#{package}-#{version}" | ||
cmd = "#{cmd} | grep -w -- #{Regexp.escape(full_package)}" | ||
end | ||
cmd | ||
end | ||
|
||
alias :check_is_installed_by_rpm :check_is_installed | ||
|
||
def get_version(package, opts=nil) | ||
"rpm -q --qf '%{VERSION}-%{RELEASE}' #{package}" | ||
end | ||
|
||
def install(package, version=nil, option='') | ||
if version | ||
full_package = "#{package}-#{version}" | ||
else | ||
full_package = package | ||
end | ||
cmd = "dnf -y #{option} install #{escape(full_package)}" | ||
end | ||
|
||
def remove(package, option='') | ||
"dnf -y #{option} remove #{package}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Specinfra::Command::Amazon::V2022::Port < Specinfra::Command::Amazon::Base::Port | ||
class << self | ||
include Specinfra::Command::Module::Ss | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Specinfra::Command::Amazon::V2022::Service < Specinfra::Command::Amazon::Base::Service | ||
class << self | ||
include Specinfra::Command::Module::Systemd | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Specinfra::Command::Amazon::V2022::Yumrepo < Specinfra::Command::Redhat::Base::Yumrepo | ||
class << self | ||
def check_exists(repository) | ||
"dnf repolist all | grep -qsE \"^[\\!\\*]?#{escape(repository)}\(\\s\|$\|\\/)\"" | ||
end | ||
|
||
def check_is_enabled(repository) | ||
"dnf repolist enabled | grep -qs \"^[\\!\\*]\\?#{escape(repository)}\"" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
property[:os] = nil | ||
set :os, :family => 'amazon', :release => '2022' | ||
|
||
describe get_command(:check_package_is_installed, 'telnet') do | ||
it { should eq 'rpm -q telnet' } | ||
end | ||
|
||
describe get_command(:check_package_is_installed, 'telnet', '0.17-48.el6.x86_64') do | ||
it { should eq 'rpm -q telnet | grep -w -- telnet\\-0\\.17\\-48\\.el6\\.x86_64' } | ||
end | ||
|
||
describe get_command(:check_package_is_installed, 'linux-headers-$(uname -r)') do | ||
it 'should be escaped (that is, command substitution should not work' do | ||
should eq 'rpm -q linux-headers-\\$\\(uname\\ -r\\)' | ||
end | ||
end | ||
|
||
describe get_command(:install_package, 'telnet') do | ||
it { should eq "dnf -y install telnet" } | ||
end | ||
|
||
describe get_command(:install_package, 'telnet', '0.17-48.el6.x86_64') do | ||
it { should eq "dnf -y install telnet-0.17-48.el6.x86_64" } | ||
end | ||
|
||
describe get_command(:install_package, 'linux-headers-$(uname -r)') do | ||
it 'should be escaped (that is, command substitution should no work)' do | ||
should eq "dnf -y install linux-headers-\\$\\(uname\\ -r\\)" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'spec_helper' | ||
|
||
property[:os] = nil | ||
set :os, :family => 'amazon', :release => '2022' | ||
|
||
describe get_command(:check_port_is_listening, '80') do | ||
it { should eq 'ss -tunl | grep -E -- :80\ ' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'spec_helper' | ||
|
||
property[:os] = nil | ||
set :os, :family => 'amazon', :release => '2022' | ||
|
||
describe get_command(:enable_service, 'httpd') do | ||
it { should eq 'systemctl enable httpd' } | ||
end | ||
|
||
describe get_command(:disable_service, 'httpd') do | ||
it { should eq 'systemctl disable httpd' } | ||
end | ||
|
||
describe get_command(:start_service, 'httpd') do | ||
it { should eq 'systemctl start httpd' } | ||
end | ||
|
||
describe get_command(:stop_service, 'httpd') do | ||
it { should eq 'systemctl stop httpd' } | ||
end | ||
|
||
describe get_command(:restart_service, 'httpd') do | ||
it { should eq 'systemctl restart httpd' } | ||
end | ||
|
||
describe get_command(:reload_service, 'httpd') do | ||
it { should eq 'systemctl reload httpd' } | ||
end | ||
|
||
describe get_command(:enable_service, 'sshd.socket') do | ||
it { should eq 'systemctl enable sshd.socket' } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'spec_helper' | ||
|
||
property[:os] = nil | ||
set :os, :family => 'amazon', :release => '2022' | ||
|
||
describe get_command(:check_yumrepo_exists, 'epel') do | ||
it { should eq "dnf repolist all | grep -qsE \"^[\\!\\*]?epel\(\\s\|$\|\\/)\"" } | ||
end | ||
|
||
describe get_command(:check_yumrepo_is_enabled, 'epel') do | ||
it { should eq "dnf repolist enabled | grep -qs \"^[\\!\\*]\\?epel\"" } | ||
end |