specinfra 2.0.0.beta15 → 2.0.0.beta16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/specinfra.rb +1 -1
- data/lib/specinfra/command/aix/base/file.rb +15 -13
- data/lib/specinfra/command/aix/base/group.rb +5 -3
- data/lib/specinfra/command/aix/base/package.rb +7 -5
- data/lib/specinfra/command/aix/base/port.rb +5 -3
- data/lib/specinfra/command/aix/base/service.rb +7 -5
- data/lib/specinfra/command/aix/base/user.rb +10 -8
- data/lib/specinfra/command/arch/base/file.rb +4 -2
- data/lib/specinfra/command/arch/base/package.rb +17 -15
- data/lib/specinfra/command/arch/base/service.rb +3 -1
- data/lib/specinfra/command/base.rb +70 -68
- data/lib/specinfra/command/base/cron.rb +8 -6
- data/lib/specinfra/command/base/file.rb +94 -92
- data/lib/specinfra/command/base/group.rb +8 -6
- data/lib/specinfra/command/base/host.rb +18 -16
- data/lib/specinfra/command/base/mail_alias.rb +5 -3
- data/lib/specinfra/command/base/package.rb +36 -34
- data/lib/specinfra/command/base/port.rb +7 -5
- data/lib/specinfra/command/base/process.rb +10 -9
- data/lib/specinfra/command/base/routing_table.rb +6 -4
- data/lib/specinfra/command/base/service.rb +19 -17
- data/lib/specinfra/command/base/user.rb +24 -22
- data/lib/specinfra/command/darwin/base/file.rb +35 -33
- data/lib/specinfra/command/darwin/base/package.rb +12 -10
- data/lib/specinfra/command/darwin/base/port.rb +5 -3
- data/lib/specinfra/command/darwin/base/service.rb +7 -5
- data/lib/specinfra/command/debian/base/package.rb +16 -14
- data/lib/specinfra/command/debian/base/service.rb +5 -3
- data/lib/specinfra/command/fedora/base/service.rb +7 -6
- data/lib/specinfra/command/fedora/v15/service.rb +3 -1
- data/lib/specinfra/command/freebsd/base/file.rb +8 -6
- data/lib/specinfra/command/freebsd/base/package.rb +13 -11
- data/lib/specinfra/command/freebsd/base/port.rb +5 -3
- data/lib/specinfra/command/freebsd/base/service.rb +4 -2
- data/lib/specinfra/command/freebsd/v10/package.rb +13 -11
- data/lib/specinfra/command/gentoo/base/package.rb +4 -2
- data/lib/specinfra/command/gentoo/base/service.rb +9 -7
- data/lib/specinfra/command/linux/base/file.rb +10 -8
- data/lib/specinfra/command/linux/base/interface.rb +13 -11
- data/lib/specinfra/command/linux/base/iptables.rb +9 -7
- data/lib/specinfra/command/linux/base/kernel_module.rb +4 -2
- data/lib/specinfra/command/linux/base/lxc_container.rb +7 -5
- data/lib/specinfra/command/linux/base/selinux.rb +9 -7
- data/lib/specinfra/command/linux/base/zfs.rb +3 -1
- data/lib/specinfra/command/nixos/base/package.rb +12 -10
- data/lib/specinfra/command/nixos/base/service.rb +3 -1
- data/lib/specinfra/command/openbsd/base/file.rb +31 -29
- data/lib/specinfra/command/openbsd/base/interface.rb +8 -13
- data/lib/specinfra/command/openbsd/base/mail_alias.rb +4 -2
- data/lib/specinfra/command/openbsd/base/package.rb +10 -8
- data/lib/specinfra/command/openbsd/base/port.rb +4 -2
- data/lib/specinfra/command/openbsd/base/service.rb +7 -5
- data/lib/specinfra/command/openbsd/base/user.rb +8 -6
- data/lib/specinfra/command/opensuse/base/service.rb +3 -1
- data/lib/specinfra/command/plamo/base/package.rb +7 -5
- data/lib/specinfra/command/plamo/base/service.rb +6 -4
- data/lib/specinfra/command/redhat/base/file.rb +5 -3
- data/lib/specinfra/command/redhat/base/package.rb +14 -12
- data/lib/specinfra/command/redhat/base/service.rb +4 -2
- data/lib/specinfra/command/redhat/base/yumrepo.rb +7 -5
- data/lib/specinfra/command/redhat/v5/iptables.rb +7 -5
- data/lib/specinfra/command/redhat/v7/service.rb +3 -1
- data/lib/specinfra/command/smartos/base/package.rb +10 -8
- data/lib/specinfra/command/smartos/base/service.rb +7 -5
- data/lib/specinfra/command/solaris/base/cron.rb +8 -6
- data/lib/specinfra/command/solaris/base/file.rb +15 -13
- data/lib/specinfra/command/solaris/base/group.rb +5 -3
- data/lib/specinfra/command/solaris/base/host.rb +7 -5
- data/lib/specinfra/command/solaris/base/ipfilter.rb +4 -2
- data/lib/specinfra/command/solaris/base/ipnat.rb +5 -3
- data/lib/specinfra/command/solaris/base/package.rb +7 -5
- data/lib/specinfra/command/solaris/base/port.rb +9 -7
- data/lib/specinfra/command/solaris/base/service.rb +14 -13
- data/lib/specinfra/command/solaris/base/user.rb +10 -8
- data/lib/specinfra/command/solaris/base/zfs.rb +3 -1
- data/lib/specinfra/command/solaris/v10/file.rb +33 -31
- data/lib/specinfra/command/solaris/v10/group.rb +4 -2
- data/lib/specinfra/command/solaris/v10/host.rb +9 -7
- data/lib/specinfra/command/solaris/v10/package.rb +7 -5
- data/lib/specinfra/command/solaris/v10/user.rb +8 -6
- data/lib/specinfra/command/suse/base/package.rb +14 -12
- data/lib/specinfra/command/suse/base/service.rb +4 -2
- data/lib/specinfra/command/ubuntu/base/ppa.rb +11 -9
- data/lib/specinfra/command/ubuntu/base/service.rb +4 -2
- data/lib/specinfra/command/windows/base.rb +11 -10
- data/lib/specinfra/command/windows/base/feature.rb +11 -9
- data/lib/specinfra/command/windows/base/file.rb +72 -71
- data/lib/specinfra/command/windows/base/group.rb +7 -5
- data/lib/specinfra/command/windows/base/host.rb +18 -16
- data/lib/specinfra/command/windows/base/hot_fix.rb +13 -11
- data/lib/specinfra/command/windows/base/iis_app_pool.rb +11 -9
- data/lib/specinfra/command/windows/base/iis_website.rb +26 -24
- data/lib/specinfra/command/windows/base/package.rb +7 -5
- data/lib/specinfra/command/windows/base/port.rb +11 -9
- data/lib/specinfra/command/windows/base/process.rb +5 -3
- data/lib/specinfra/command/windows/base/registry_key.rb +36 -35
- data/lib/specinfra/command/windows/base/scheduled_task.rb +6 -4
- data/lib/specinfra/command/windows/base/service.rb +21 -19
- data/lib/specinfra/command/windows/base/user.rb +16 -14
- data/lib/specinfra/runner.rb +1 -2
- data/lib/specinfra/version.rb +1 -1
- data/spec/command/base_spec.rb +12 -4
- data/spec/command/module/systemd_spec.rb +14 -4
- data/spec/command/redhat/interface_spec.rb +1 -1
- metadata +1 -2
- data/lib/specinfra/command/smartos/tmp.rb +0 -8
@@ -1,22 +1,24 @@
|
|
1
1
|
class Specinfra::Command::Debian::Base::Package < Specinfra::Command::Linux::Base::Package
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_installed(package, version=nil)
|
4
|
+
escaped_package = escape(package)
|
5
|
+
if version
|
6
|
+
cmd = "dpkg-query -f '${Status} ${Version}' -W #{escaped_package} | grep -E '^(install|hold) ok installed #{escape(version)}$'"
|
7
|
+
else
|
8
|
+
cmd = "dpkg-query -f '${Status}' -W #{escaped_package} | grep -E '^(install|hold) ok installed$'"
|
9
|
+
end
|
10
|
+
cmd
|
8
11
|
end
|
9
|
-
cmd
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
+
alias :check_is_installed_by_apt :check_is_installed
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def install(package)
|
16
|
+
"apt-get -y install #{package}"
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def get_version(package, opts=nil)
|
20
|
+
"dpkg-query -f '${Status} ${Version}' -W #{package} | sed -n 's/^install ok installed //p'"
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Specinfra::Command::Debian::Base::Service < Specinfra::Command::Linux::Base::Service
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_enabled(service, level=3)
|
4
|
+
# Until everything uses Upstart, this needs an OR.
|
5
|
+
"ls /etc/rc#{level}.d/ | grep -- '^S..#{escape(service)}' || grep 'start on' /etc/init/#{escape(service)}.conf"
|
6
|
+
end
|
5
7
|
end
|
6
8
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
class Specinfra::Command::Fedora::Base::Service < Specinfra::Command::Redhat::Base::Service
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class << self
|
3
|
+
def create
|
4
|
+
if os[:release].to_i < 15
|
5
|
+
self
|
6
|
+
else
|
7
|
+
Specinfra::Command::Fedora::V15::Service
|
8
|
+
end
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
10
|
-
|
@@ -1,10 +1,12 @@
|
|
1
1
|
class Specinfra::Command::Freebsd::Base::File < Specinfra::Command::Base::File
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class << self
|
3
|
+
def check_has_mode(file, mode)
|
4
|
+
regexp = "^#{mode}$"
|
5
|
+
"stat -f%Lp #{escape(file)} | grep -- #{escape(regexp)}"
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
def get_mode(file)
|
9
|
+
"stat -f%Lp #{escape(file)}"
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
class Specinfra::Command::Freebsd::Base::Package < Specinfra::Command::Base::Package
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_installed(package, version=nil)
|
4
|
+
if version
|
5
|
+
"pkg_info -I #{escape(package)}-#{escape(version)}"
|
6
|
+
else
|
7
|
+
"pkg_info -Ix #{escape(package)}"
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def install(package)
|
12
|
+
"pkg_add -r install #{package}"
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def get_version(package, opts=nil)
|
16
|
+
"pkg_info -Ix #{escape(package)} | cut -f 1 -w | sed -n 's/^#{escape(package)}-//p'"
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class Specinfra::Command::Freebsd::Base::Port < Specinfra::Command::Base::Port
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_listening(port, options={})
|
4
|
+
regexp = ":#{port} "
|
5
|
+
"sockstat -46l -p #{port} | grep -- #{escape(regexp)}"
|
6
|
+
end
|
5
7
|
end
|
6
8
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class Specinfra::Command::Freebsd::Base::Service < Specinfra::Command::Base::Service
|
2
|
-
|
3
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_enabled(service, level=3)
|
4
|
+
"service -e | grep -- #{escape(service)}"
|
5
|
+
end
|
4
6
|
end
|
5
7
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
class Specinfra::Command::Freebsd::V10::Package < Specinfra::Command::Freebsd::Base::Package
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_installed(package, version=nil)
|
4
|
+
if version
|
5
|
+
"pkg query %v #{escape(package)} | grep -- #{escape(version)}"
|
6
|
+
else
|
7
|
+
"pkg info #{escape(package)}"
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def install(package)
|
12
|
+
"pkg install -y #{package}"
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
def get_version(package, opts=nil)
|
16
|
+
"pkg query %v #{escape(package)}"
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class Specinfra::Command::Gentoo::Base::Package < Specinfra::Command::Linux::Base::Package
|
2
|
-
|
3
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_installed(package, version=nil)
|
4
|
+
"eix #{escape(package)} --installed"
|
5
|
+
end
|
4
6
|
end
|
5
7
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
class Specinfra::Command::Gentoo::Base::Service < Specinfra::Command::Linux::Base::Service
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_enabled(service, level=3)
|
4
|
+
regexp = "^\\s*#{service}\\s*|\\s*\\(boot\\|default\\)"
|
5
|
+
"rc-update show | grep -- #{escape(regexp)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def check_is_running(service)
|
9
|
+
"/etc/init.d/#{escape(service)} status"
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
@@ -1,13 +1,15 @@
|
|
1
1
|
class Specinfra::Command::Linux::Base::File < Specinfra::Command::Base::File
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_accessible_by_user(file, user, access)
|
4
|
+
"su -s /bin/sh -c \"test -#{access} #{file}\" #{user}"
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def check_is_immutable(file)
|
8
|
+
check_attribute(file, 'i')
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
def check_attribute(file, attribute)
|
12
|
+
"lsattr -d #{escape(file)} 2>&1 | awk '$1~/^-*#{escape(attribute)}-*$/ {exit 0} {exit 1}'"
|
13
|
+
end
|
12
14
|
end
|
13
15
|
end
|
@@ -1,17 +1,19 @@
|
|
1
1
|
class Specinfra::Command::Linux::Base::Interface < Specinfra::Command::Base::Interface
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class << self
|
3
|
+
def get_speed_of(name)
|
4
|
+
"ethtool #{name} | grep Speed | gawk '{print gensub(/Speed: ([0-9]+)Mb\\\/s/,\"\\\\1\",\"\")}'"
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
def check_has_ipv4_address(interface, ip_address)
|
8
|
+
ip_address = ip_address.dup
|
9
|
+
if ip_address =~ /\/\d+$/
|
10
|
+
ip_address << " "
|
11
|
+
else
|
12
|
+
ip_address << "/"
|
13
|
+
end
|
14
|
+
ip_address.gsub!(".", "\\.")
|
15
|
+
"ip addr show #{interface} | grep 'inet #{ip_address}'"
|
12
16
|
end
|
13
|
-
ip_address.gsub!(".", "\\.")
|
14
|
-
"ip addr show #{interface} | grep 'inet #{ip_address}'"
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
class Specinfra::Command::Linux::Base::Iptables < Specinfra::Command::Base::Iptables
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class << self
|
3
|
+
def check_has_rule(rule, table=nil, chain=nil)
|
4
|
+
cmd = "iptables"
|
5
|
+
cmd += " -t #{escape(table)}" if table
|
6
|
+
cmd += " -S"
|
7
|
+
cmd += " #{escape(chain)}" if chain
|
8
|
+
cmd += " | grep -- #{escape(rule)}"
|
9
|
+
cmd
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
class Specinfra::Command::Linux::Base::LxcContainer < Specinfra::Command::Base::LxcContainer
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
class << self
|
3
|
+
def check_exists(container)
|
4
|
+
"lxc-ls -1 | grep -w #{escape(container)}"
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
def check_is_running(container)
|
8
|
+
"lxc-info -n #{escape(container)} -s | grep -w RUNNING"
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
class Specinfra::Command::Linux::Base::Selinux < Specinfra::Command::Base::Selinux
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
class << self
|
3
|
+
def check_has_mode(mode)
|
4
|
+
cmd = ""
|
5
|
+
cmd += "test ! -f /etc/selinux/config || (" if mode == "disabled"
|
6
|
+
cmd += "getenforce | grep -i -- #{escape(mode)} "
|
7
|
+
cmd += "&& grep -i -- ^SELINUX=#{escape(mode)}$ /etc/selinux/config"
|
8
|
+
cmd += ")" if mode == "disabled"
|
9
|
+
cmd
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
@@ -1,15 +1,17 @@
|
|
1
1
|
class Specinfra::Command::Nixos::Base::Package < Specinfra::Command::Linux::Base::Package
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class << self
|
3
|
+
def check_is_installed(package, version=nil)
|
4
|
+
if version
|
5
|
+
"nix-store -q --references /var/run/current-system/sw | grep #{escape(package)}-#{escape(version)}"
|
6
|
+
else
|
7
|
+
"nix-store -q --references /var/run/current-system/sw | grep #{escape(package)}"
|
8
|
+
end
|
7
9
|
end
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
+
alias :check_is_installed_by_nix :check_is_installed
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def install(package)
|
14
|
+
"nix-env -i #{package}"
|
15
|
+
end
|
16
|
+
end
|
15
17
|
end
|
@@ -1,39 +1,41 @@
|
|
1
1
|
class Specinfra::Command::Openbsd::Base::File < Specinfra::Command::Base::File
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
class << self
|
3
|
+
def check_has_md5checksum(file, expected)
|
4
|
+
regexp = "^#{expected}"
|
5
|
+
"cksum -qa md5 #{escape(file)} | grep -w #{escape(regexp)}"
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
def check_has_sha256checksum(file, expected)
|
9
|
+
regexp = "^#{expected}"
|
10
|
+
"cksum -qa sha256 #{escape(file)} | grep -w #{escape(regexp)}"
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def check_is_linked_to(link, target)
|
14
|
+
"stat -f %Y #{escape(link)} | grep -- #{escape(target)}"
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def check_has_mode(file, mode)
|
18
|
+
regexp = "^#{mode}$"
|
19
|
+
"stat -f%Lp #{escape(file)} | grep #{escape(regexp)}"
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
def check_is_owned_by(file, owner)
|
23
|
+
regexp = "^#{owner}$"
|
24
|
+
"stat -f %Su #{escape(file)} | grep -- #{escape(regexp)}"
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
def check_is_grouped(file, group)
|
28
|
+
regexp = "^#{group}$"
|
29
|
+
"stat -f %Sg #{escape(file)} | grep -- #{escape(regexp)}"
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def check_is_mounted(path)
|
33
|
+
regexp = "on #{path} "
|
34
|
+
"mount | grep #{escape(regexp)}"
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
def get_mode(file)
|
38
|
+
"stat -f%Lp #{escape(file)}"
|
39
|
+
end
|
38
40
|
end
|
39
41
|
end
|