source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/opensuse/base/service.rb | Ruby | mit | 300 | master | 353 | class Specinfra::Command::Opensuse::Base::Service < Specinfra::Command::Suse::Base::Service
class << self
include Specinfra::Command::Module::Systemd
def check_is_running(service)
"service #{escape(service)} status"
end
def check_is_enabled(service, level=nil)
"systemctl is-enabled #{esc... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/service.rb | Ruby | mit | 300 | master | 563 | class Specinfra::Command::Darwin::Base::Service < Specinfra::Command::Base::Service
class << self
def check_is_enabled(service, level=nil)
"launchctl list | grep #{escape(service)}"
end
def check_is_enabled_under_homebrew(service)
"brew services list | grep #{escape(service)}"
end
de... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/interface.rb | Ruby | mit | 300 | master | 1,837 | class Specinfra::Command::Darwin::Base::Interface < Specinfra::Command::Base::Interface
class << self
def check_exists(name)
"ifconfig #{name}"
end
def check_has_ipv4_address(interface, ip_address)
ip_address = ip_address.dup
if ip_address =~ /\/\d+$/
# remove the prefix - bette... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/process.rb | Ruby | mit | 300 | master | 259 | class Specinfra::Command::Darwin::Base::Process < Specinfra::Command::Base::Process
class << self
def get(process, opts)
"ps -A -c -o #{opts[:format]},command | grep -E -m 1 ^\\ *[0-9]+\\ +#{escape(process)}$ | awk '{print $1}'"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/port.rb | Ruby | mit | 300 | master | 507 | class Specinfra::Command::Darwin::Base::Port < Specinfra::Command::Base::Port
class << self
def check_is_listening(port, options={})
regexp = ":#{port} "
protocol = options[:protocol] || 'tcp'
protocol_options = case protocol
when 'tcp'
"-iTCP -sTCP:LISTEN"
when 'tcp6'
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/user.rb | Ruby | mit | 300 | master | 1,972 | class Specinfra::Command::Darwin::Base::User < Specinfra::Command::Base::User
class << self
def check_has_home_directory(user, path_to_home)
"#{get_home_directory(user)} | grep -E '^#{escape(path_to_home)}$'"
end
def check_has_login_shell(user, path_to_shell)
"finger #{escape(user)} | grep -E... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/host.rb | Ruby | mit | 300 | master | 1,737 | class Specinfra::Command::Darwin::Base::Host < Specinfra::Command::Base::Host
class << self
def check_is_resolvable(name, type)
if type == "dns"
## try to resolve either A or AAAA record; grep is used to return the appropriate exit code
%Q{dig +search +short +time=1 -q #{escape(name)} a #{es... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/package.rb | Ruby | mit | 300 | master | 1,825 | class Specinfra::Command::Darwin::Base::Package < Specinfra::Command::Base::Package
class << self
def check_is_installed(package, version=nil)
escaped_package = escape(::File.basename(package))
if version
cmd = %Q[brew info #{escaped_package} | grep -E "^$(brew --prefix)/Cellar/#{escaped_packa... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/group.rb | Ruby | mit | 300 | master | 778 | class Specinfra::Command::Darwin::Base::Group < Specinfra::Command::Base::Group
class << self
def get_gid(group)
"dscl . -read /Groups/#{escape(group)} PrimaryGroupID | awk '{ print $2 }'"
end
def update_gid(group, gid)
"dscl . -create /Groups/#{escape(group)} PrimaryGroupID #{escape(gid)}"... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/file.rb | Ruby | mit | 300 | master | 1,266 | class Specinfra::Command::Darwin::Base::File < Specinfra::Command::Base::File
class << self
def check_is_accessible_by_user(file, user, access)
"sudo -u #{user} -s /bin/test -#{access} #{file}"
end
def get_md5sum(file)
"openssl md5 #{escape(file)} | cut -d'=' -f2 | cut -c 2-"
end
def... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/darwin/base/inventory.rb | Ruby | mit | 300 | master | 505 | class Specinfra::Command::Darwin::Base::Inventory < Specinfra::Command::Base::Inventory
class << self
def get_memory
'false'
end
def get_cpu
'false'
end
def get_kernel
'false'
end
def get_hostname
'hostname -s'
end
def get_domain
'hostname -f | ' +... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/base/service.rb | Ruby | mit | 300 | master | 357 | class Specinfra::Command::Redhat::Base::Service < Specinfra::Command::Linux::Base::Service
class << self
def create(os_info=nil)
release = (os_info || os)[:release].to_i
# Dirty hack for Amazon Linux
if release < 7 || release > 2000
self
else
Specinfra::Command::Redhat::V7:... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/base/yumrepo.rb | Ruby | mit | 300 | master | 540 | class Specinfra::Command::Redhat::Base::Yumrepo < Specinfra::Command::Linux::Base::Yumrepo
class << self
def create(os_info=nil)
if (os_info || os)[:release].to_i < 8
self
else
Specinfra::Command::Redhat::V8::Yumrepo
end
end
def check_exists(repository)
"yum repoli... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/base/package.rb | Ruby | mit | 300 | master | 850 | class Specinfra::Command::Redhat::Base::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_pack... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/base/port.rb | Ruby | mit | 300 | master | 341 | class Specinfra::Command::Redhat::Base::Port < Specinfra::Command::Base::Port
class << self
def create(os_info=nil)
release = (os_info || os)[:release].to_i
# Dirty hack for Amazon Linux
if release < 7 || release > 2000
self
else
Specinfra::Command::Redhat::V7::Port
e... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/base/selinux_module.rb | Ruby | mit | 300 | master | 297 | class Specinfra::Command::Redhat::Base::SelinuxModule < Specinfra::Command::Linux::Base::SelinuxModule
class << self
def create(os_info=nil)
if (os_info || os)[:release].to_i < 8
self
else
Specinfra::Command::Redhat::V8::SelinuxModule
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/base/host.rb | Ruby | mit | 300 | master | 341 | class Specinfra::Command::Redhat::Base::Host < Specinfra::Command::Base::Host
class << self
def create(os_info=nil)
release = (os_info || os)[:release].to_i
# Dirty hack for Amazon Linux
if release < 7 || release > 2000
self
else
Specinfra::Command::Redhat::V7::Host
e... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/v8/selinux_module.rb | Ruby | mit | 300 | master | 316 | class Specinfra::Command::Redhat::V8::SelinuxModule < Specinfra::Command::Redhat::Base::SelinuxModule
class << self
def check_is_installed(name, version=nil)
"semodule -l | grep $'^#{escape(name)}'"
end
def check_is_enabled(name)
"semodule -l | grep $'^#{escape(name)}'"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/v8/yumrepo.rb | Ruby | mit | 300 | master | 368 | class Specinfra::Command::Redhat::V8::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 \"^[\\!\\... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/v5/iptables.rb | Ruby | mit | 300 | master | 303 | class Specinfra::Command::Redhat::V5::Iptables < Specinfra::Command::Redhat::Base::Iptables
class << self
def check_has_rule(rule, table=nil, chain=nil)
cmd = "iptables-save"
cmd += " -t #{escape(table)}" if table
cmd += " | grep -- #{escape(rule)}"
cmd
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/redhat/v7/host.rb | Ruby | mit | 300 | master | 544 | class Specinfra::Command::Redhat::V7::Host < Specinfra::Command::Redhat::Base::Host
class << self
def check_is_reachable(host, port, proto, timeout)
if port.nil?
"ping -w #{escape(timeout)} -c 2 -n #{escape(host)}"
else
# RHEL7 comes with ncat which does no longer sport the -z option
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/v10/file.rb | Ruby | mit | 300 | master | 1,587 | class Specinfra::Command::Solaris::V10::File < Specinfra::Command::Solaris::Base::File
class << self
# reference: http://perldoc.perl.org/functions/stat.html
def check_has_mode(file, mode)
regexp = "^#{mode}$"
"perl -e 'printf \"%o\", (stat shift)[2]&07777' #{escape(file)} | grep -- #{escape(rege... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/v10/host.rb | Ruby | mit | 300 | master | 419 | class Specinfra::Command::Solaris::V10::Host < Specinfra::Command::Solaris::Base::Host
class << self
def check_is_reachable(host, port, proto, timeout)
if port.nil?
"ping -n #{escape(host)} #{escape(timeout)}"
elsif proto == 'tcp'
"echo 'quit' | mconnect -p #{escape(port)} #{escape(hos... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/v10/user.rb | Ruby | mit | 300 | master | 415 | class Specinfra::Command::Solaris::V10::User < Specinfra::Command::Solaris::Base::User
class << self
def check_belongs_to_group(user, group)
"id -ap #{escape(user)} | grep -- #{escape(group)}"
end
def check_has_authorized_key(user, key)
key.sub!(/\s+\S*$/, '') if key.match(/^\S+\s+\S+\s+\S*$/... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/v10/group.rb | Ruby | mit | 300 | master | 202 | class Specinfra::Command::Solaris::V10::Group < Specinfra::Command::Solaris::Base::Group
class << self
def check_exists(group)
"getent group | grep -w -- #{escape(group)}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/v10/package.rb | Ruby | mit | 300 | master | 310 | class Specinfra::Command::Solaris::V10::Package < Specinfra::Command::Solaris::Base::Package
class << self
def check_is_installed(package, version=nil)
cmd = "pkginfo -q #{escape(package)}"
if version
cmd = "#{cmd} | grep -- #{escape(version)}"
end
cmd
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/file.rb | Ruby | mit | 300 | master | 950 | class Specinfra::Command::Solaris::Base::File < Specinfra::Command::Base::File
class << self
def check_contains_within(file, expected_pattern, from=nil, to=nil)
from ||= '1'
to ||= '$'
sed = "sed -n #{escape(from)},#{escape(to)}p #{escape(file)}"
sed_end = "sed -n 1,#{escape(to)}p"
c... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/host.rb | Ruby | mit | 300 | master | 361 | class Specinfra::Command::Solaris::Base::Host < Specinfra::Command::Base::Host
class << self
def check_is_reachable(host, port, proto, timeout)
if port.nil?
"ping -n #{escape(host)} #{escape(timeout)}"
else
"nc -vvvvz#{escape(proto[0].chr)} -w #{escape(timeout)} #{escape(host)} #{escap... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/user.rb | Ruby | mit | 300 | master | 524 | class Specinfra::Command::Solaris::Base::User < Specinfra::Command::Base::User
class << self
def check_belongs_to_group(user, group)
"id -Gn #{escape(user)} | grep -- #{escape(group)}"
end
def check_has_home_directory(user, path_to_home)
"getent passwd #{escape(user)} | cut -f 6 -d ':' | grep... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/cron.rb | Ruby | mit | 300 | master | 418 | class Specinfra::Command::Solaris::Base::Cron < Specinfra::Command::Base::Cron
class << self
def check_has_entry(user, entry)
entry_escaped = entry.gsub(/\*/, '\\*').gsub(/\[/, '\\[').gsub(/\]/, '\\]').gsub(/\%/, '\\%')
if user.nil?
"crontab -l | grep -- #{escape(entry_escaped)}"
else
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/kernel_module.rb | Ruby | mit | 300 | master | 240 | class Specinfra::Command::Solaris::Base::KernelModule < Specinfra::Command::Base::KernelModule
class << self
def check_is_loaded(name)
"modinfo -c | awk '$3 == \"#{escape(name)}\" { print $4 }' | grep ^LOADED"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/package.rb | Ruby | mit | 300 | master | 322 | class Specinfra::Command::Solaris::Base::Package < Specinfra::Command::Base::Package
class << self
def check_is_installed(package, version=nil)
cmd = "pkg list -H #{escape(package)} 2> /dev/null"
if version
cmd = "#{cmd} | grep -qw -- #{escape(version)}"
end
cmd
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/port.rb | Ruby | mit | 300 | master | 461 | class Specinfra::Command::Solaris::Base::Port < Specinfra::Command::Base::Port
class << self
def check_is_listening(port, opts=nil)
regexp = "\\.#{port} "
"netstat -an 2> /dev/null | grep -- LISTEN | grep -- #{escape(regexp)}"
end
def check_is_listening_with_protocol(port, protocol)
reg... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/ipnat.rb | Ruby | mit | 300 | master | 235 | class Specinfra::Command::Solaris::Base::Ipnat < Specinfra::Command::Base::Ipnat
class << self
def check_has_rule(rule)
regexp = "^#{rule}$"
"ipnat -l 2> /dev/null | grep -- #{escape(regexp)}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/group.rb | Ruby | mit | 300 | master | 272 | class Specinfra::Command::Solaris::Base::Group < Specinfra::Command::Base::Group
class << self
def check_has_gid(group, gid)
regexp = "^#{group}:"
"getent group | grep -- #{escape(regexp)} | cut -f 3 -d ':' | grep -w -- #{escape(gid)}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/service.rb | Ruby | mit | 300 | master | 705 | class Specinfra::Command::Solaris::Base::Service < Specinfra::Command::Base::Service
class << self
def check_is_enabled(service, level=nil)
"svcs -l #{escape(service)} 2> /dev/null | egrep '^enabled *true$'"
end
def check_is_running(service)
"svcs -H -o state #{escape(service)} 2> /dev/null |... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/ipfilter.rb | Ruby | mit | 300 | master | 209 | class Specinfra::Command::Solaris::Base::Ipfilter < Specinfra::Command::Base::Ipfilter
class << self
def check_has_rule(rule)
"ipfstat -io 2> /dev/null | grep -- #{escape(rule)}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/base/inventory.rb | Ruby | mit | 300 | master | 1,286 | class Specinfra::Command::Solaris::Base::Inventory < Specinfra::Command::Base::Inventory
class << self
def get_memory
'false'
end
def get_cpu
'false'
end
def get_hostname
'uname -n'
end
def get_domain
# There is no sure way to get the hostname like on linux
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/solaris/v11/user.rb | Ruby | mit | 300 | master | 410 | class Specinfra::Command::Solaris::V11::User < Specinfra::Command::Solaris::Base::User
class << self
def get_minimum_days_between_password_change(user)
"passwd -s #{escape(user)} | sed 's/ \\{1,\\}/%/g' | tr '%' '\n' | sed '4q;d'"
end
def get_maximum_days_between_password_change(user)
"passwd... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/gentoo/base/package.rb | Ruby | mit | 300 | master | 680 | class Specinfra::Command::Gentoo::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
"eix #{escape(package)} --installed | grep -v \"No matches found\""
end
def get_version(package, opts=nil)
"equery -q list #{package} | sed -e ... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/alpine/base/process.rb | Ruby | mit | 300 | master | 618 | class Specinfra::Command::Alpine::Base::Process < Specinfra::Command::Base
class << self
def get(process, opts)
col = opts[:format].chomp('=')
if col == 'args'
"ps -o #{col} | grep #{escape(process)} | head -1"
else
"ps -o #{col},args | grep -E '\\s+#{process}' | awk '{ print $1 ... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/alpine/base/package.rb | Ruby | mit | 300 | master | 709 | class Specinfra::Command::Alpine::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version = nil)
if version.nil? then
pkg = escape(package)
"apk info -qe #{pkg}"
else
pkg = "#{package}-#{version}"
"apk info -v | gre... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/alpine/base/host.rb | Ruby | mit | 300 | master | 387 | class Specinfra::Command::Alpine::Base::Host < Specinfra::Command::Base::Host
class << self
def check_is_reachable(host, port, proto, timeout)
if port.nil?
"ping -w #{escape(timeout)} -c 2 -n #{escape(host)}"
else
"nc -w #{escape(timeout)} -vvvvz#{proto.downcase.start_with?('u') ? 'u' ... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/voidlinux/base/package.rb | Ruby | mit | 300 | master | 622 | class Specinfra::Command::Voidlinux::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
"xbps-query -S #{escape(package)} | grep -q 'state: installed'"
end
alias :check_is_installed_by_xbps :check_is_installed
def get_version(pac... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/ss.rb | Ruby | mit | 300 | master | 1,516 | module Specinfra
module Command
module Module
module Ss
def check_is_listening(port, options={})
if options[:local_address]
pattern = inaddr_any_to_asterisk(options[:local_address]).map { |l| " #{l}:#{port} " }
pattern = pattern.join('|')
else
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/zfs.rb | Ruby | mit | 300 | master | 596 | module Specinfra
module Command
module Module
module Zfs
def check_exists(zfs)
"zfs list -H #{escape(zfs)}"
end
def check_has_property(zfs, property=nil)
commands = []
property.sort.each do |key, value|
regexp = "^#{value}$"
co... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/systemd.rb | Ruby | mit | 300 | master | 271 | module Specinfra
module Command
module Module
module Systemd
include Specinfra::Command::Module::Service::Systemd
extend Specinfra::Command::Module::Service::Delegator
def_delegator_service_under :systemd
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/openrc.rb | Ruby | mit | 300 | master | 267 | module Specinfra
module Command
module Module
module OpenRC
include Specinfra::Command::Module::Service::OpenRC
extend Specinfra::Command::Module::Service::Delegator
def_delegator_service_under :openrc
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/runit.rb | Ruby | mit | 300 | master | 264 | module Specinfra
module Command
module Module
module Runit
include Specinfra::Command::Module::Service::Runit
extend Specinfra::Command::Module::Service::Delegator
def_delegator_service_under :runit
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/init.rb | Ruby | mit | 300 | master | 1,009 | module Specinfra
module Command
module Module
module Service
module Init
def check_is_enabled_under_init(service, level=3)
"chkconfig --list #{escape(service)} | grep #{level}:on"
end
def check_is_running_under_init(service)
"service #{escape(se... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/runit.rb | Ruby | mit | 300 | master | 1,007 | module Specinfra
module Command
module Module
module Service
module Runit
def check_is_running_under_runit(service)
"sv status #{escape(service)} | grep -E '^run: '"
end
def check_is_enabled_under_runit(service)
"test ! -f /etc/sv/#{escape(servi... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/upstart.rb | Ruby | mit | 300 | master | 267 | module Specinfra
module Command
module Module
module Service
module Upstart
def check_is_running_under_upstart(service)
"initctl status #{escape(service)} | grep running"
end
end
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/delegator.rb | Ruby | mit | 300 | master | 876 | module Specinfra
module Command
module Module
module Service
module Delegator
def def_delegator_service_under(under)
self.send(:alias_method, :check_is_enabled, :"check_is_enabled_under_#{under}")
self.send(:alias_method, :check_is_running, :"check_is_running_under_... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/systemd.rb | Ruby | mit | 300 | master | 1,051 | module Specinfra
module Command
module Module
module Service
module Systemd
def check_is_enabled_under_systemd(service, level=nil)
"systemctl --quiet is-enabled #{escape(service)}"
end
def check_is_running_under_systemd(service)
"systemctl is-ac... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/daemontools.rb | Ruby | mit | 300 | master | 1,379 | module Specinfra
module Command
module Module
module Service
module Daemontools
def check_is_enabled_under_daemontools(service)
"test -L #{service_dir}/#{escape(service)} && test -f #{service_dir}/#{escape(service)}/run"
end
def check_is_running_under_daemo... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/monit.rb | Ruby | mit | 300 | master | 226 | module Specinfra
module Command
module Module
module Service
module Monit
def check_is_monitored_by_monit(service)
"monit status"
end
end
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/supervisor.rb | Ruby | mit | 300 | master | 279 | module Specinfra
module Command
module Module
module Service
module Supervisor
def check_is_running_under_supervisor(service)
"supervisorctl status #{escape(service)} | grep RUNNING"
end
end
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/openrc.rb | Ruby | mit | 300 | master | 1,046 | module Specinfra
module Command
module Module
module Service
module OpenRC
def check_is_enabled_under_openrc(service, level=3)
"rc-update show boot default | grep -w #{escape(service)}"
end
def check_is_running_under_openrc(service)
"/etc/init.d... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/module/service/god.rb | Ruby | mit | 300 | master | 239 | module Specinfra
module Command
module Module
module Service
module God
def check_is_monitored_by_god(service)
"god status #{escape(service)}"
end
end
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/arch/base/package.rb | Ruby | mit | 300 | master | 909 | class Specinfra::Command::Arch::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package,version=nil)
if version
grep = version.include?('-') ? "^#{escape(version)}$" : "^#{escape(version)}-"
"pacman -Q #{escape(package)} | awk '{print $2}' | grep... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/amazon/v2022/package.rb | Ruby | mit | 300 | master | 851 | 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_pac... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/amazon/v2022/yumrepo.rb | Ruby | mit | 300 | master | 371 | 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 \"^[\\... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/ubuntu/base/service.rb | Ruby | mit | 300 | master | 429 | class Specinfra::Command::Ubuntu::Base::Service < Specinfra::Command::Debian::Base::Service
class << self
def check_is_running(service)
"service #{escape(service)} status && service #{escape(service)} status | egrep 'running|online'"
end
def create(os_info=nil)
if (os_info || os)[:release].to... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/ubuntu/base/port.rb | Ruby | mit | 300 | master | 272 | class Specinfra::Command::Ubuntu::Base::Port < Specinfra::Command::Linux::Base::Port
class << self
def create(os_info=nil)
if (os_info || os)[:release].to_i < 18
self
else
Specinfra::Command::Ubuntu::V18::Port
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/ubuntu/base/ppa.rb | Ruby | mit | 300 | master | 530 | class Specinfra::Command::Ubuntu::Base::Ppa < Specinfra::Command::Debian::Base::Ppa
class << self
def check_exists(package)
%Q{find /etc/apt/ -name \*.list | xargs grep -o -E "deb +[\\"']?http://ppa.launchpad.net/#{to_apt_line_uri(package)}"}
end
def check_is_enabled(package)
%Q{find /etc/apt... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/port.rb | Ruby | mit | 300 | master | 246 | class Specinfra::Command::Freebsd::Base::Port < Specinfra::Command::Base::Port
class << self
def check_is_listening(port, options={})
regexp = ":#{port} "
"sockstat -46l -p #{port} | grep -- #{escape(regexp)}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/process.rb | Ruby | mit | 300 | master | 476 | class Specinfra::Command::Freebsd::Base::Process < Specinfra::Command::Base::Process
class << self
def get(process, opts)
"ps -p `pgrep -xn #{escape(process)}` -o #{opts[:format]}"
end
def count(process)
"pgrep #{escape(process)} | wc -l"
end
def check_is_running(process)
"pgre... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/user.rb | Ruby | mit | 300 | master | 1,709 | class Specinfra::Command::Freebsd::Base::User < Specinfra::Command::Base::User
class << self
def create(os_info=nil)
if (os_info || os)[:release].to_i < 7
Specinfra::Command::Freebsd::V6::User
else
self
end
end
def get_minimum_days_between_password_change(user)
'ec... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/interface.rb | Ruby | mit | 300 | master | 2,062 | class Specinfra::Command::Freebsd::Base::Interface < Specinfra::Command::Base::Interface
class << self
def check_exists(name)
"ifconfig #{name}"
end
def get_speed_of(name)
"ifconfig #{name} | awk '/media:/{if(match($0,/[0-9]+/)){ print substr($0, RSTART, RLENGTH);}}'"
end
def get_mtu... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/routing_table.rb | Ruby | mit | 300 | master | 296 | class Specinfra::Command::Freebsd::Base::RoutingTable < Specinfra::Command::Base::RoutingTable
class << self
def check_has_entry(destination)
%Q{netstat -rnW | grep #{destination} | awk '{print $1, "via", $2, "dev", $6, " "}'}
end
alias :get_entry :check_has_entry
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/host.rb | Ruby | mit | 300 | master | 948 | class Specinfra::Command::Freebsd::Base::Host < Specinfra::Command::Base::Host
class << self
def check_is_reachable(host, port, proto, timeout)
if port.nil?
"ping -t #{escape(timeout)} -c 2 -n #{escape(host)}"
else
"nc -vvvvz#{escape(proto[0].chr)} #{escape(host)} #{escape(port)} -w #{... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/service.rb | Ruby | mit | 300 | master | 292 | class Specinfra::Command::Freebsd::Base::Service < Specinfra::Command::Base::Service
class << self
def check_is_enabled(service, level=3)
"service #{escape(service)} enabled"
end
def check_is_running(service)
"service #{escape(service)} onestatus"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/file.rb | Ruby | mit | 300 | master | 1,154 | class Specinfra::Command::Freebsd::Base::File < Specinfra::Command::Base::File
class << self
def check_is_grouped(file, group)
regexp = "^#{group}$"
"stat -f%Sg #{escape(file)} | grep -- #{escape(regexp)}"
end
def get_owner_group(file)
"stat -f%Sg #{escape(file)}"
end
def check... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/inventory.rb | Ruby | mit | 300 | master | 540 | class Specinfra::Command::Freebsd::Base::Inventory < Specinfra::Command::Base::Inventory
class << self
def get_memory
'false'
end
def get_cpu
'false'
end
def get_hostname
'hostname -s'
end
def get_domain
'hostname -f | ' +
'awk -v h=`hostname -s` \'$1 ~ h {... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/package.rb | Ruby | mit | 300 | master | 847 | class Specinfra::Command::Freebsd::Base::Package < Specinfra::Command::Base::Package
class << self
def check_is_installed(package, version=nil)
if version
"pkg query %v #{escape(package)} | grep -- #{escape(version)}"
else
"pkg info -e #{escape(package)}"
end
end
alias :... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/base/group.rb | Ruby | mit | 300 | master | 391 | class Specinfra::Command::Freebsd::Base::Group < Specinfra::Command::Base::Group
class << self
def update_gid(group, gid)
"pw groupmod #{escape(group)} -g #{escape(gid)}"
end
def add(group, options)
command = %w[pw group add]
command << escape(group)
command << '-g' << escape(opti... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/v11/interface.rb | Ruby | mit | 300 | master | 373 | class Specinfra::Command::Freebsd::V11::Interface < Specinfra::Command::Freebsd::Base::Interface
class << self
def get_ipv4_address(interface)
"ifconfig -f inet:cidr #{interface} inet | awk '/inet /{print $2}'"
end
def get_ipv6_address(interface)
"ifconfig -f inet6:cidr #{interface} inet6 | a... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/v6/package.rb | Ruby | mit | 300 | master | 543 | class Specinfra::Command::Freebsd::V6::Package < Specinfra::Command::Base::Package
class << self
def check_is_installed(package, version=nil)
if version
"pkg_info -I #{escape(package)}-#{escape(version)}"
else
"pkg_info -Ix #{escape(package)}"
end
end
def install(package... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/v6/service.rb | Ruby | mit | 300 | master | 210 | class Specinfra::Command::Freebsd::V6::Service < Specinfra::Command::Base::Service
class << self
def check_is_enabled(service, level=3)
"service -e | grep -- /#{escape(service)}$"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/v6/user.rb | Ruby | mit | 300 | master | 611 | class Specinfra::Command::Freebsd::V6::User < Specinfra::Command::Freebsd::Base::User
class << self
def check_has_home_directory(user, path_to_home)
"pw user show #{escape(user)} | cut -f 9 -d ':' | grep -w -- #{escape(path_to_home)}"
end
def check_has_login_shell(user, path_to_shell)
"pw use... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/freebsd/v8/package.rb | Ruby | mit | 300 | master | 1,744 | class Specinfra::Command::Freebsd::V8::Package < Specinfra::Command::Freebsd::Base::Package
class << self
def pkg_info_pattern(package)
# allow portorigin (origin/portname) as package argument, so that we get
# similar answers from either "pkg info" and "pkg_info"
"^#{package.split('/', 2)[-1]}-... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/nixos/base/package.rb | Ruby | mit | 300 | master | 564 | class Specinfra::Command::Nixos::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
if version
"nix-store -q --references /var/run/current-system/sw | grep #{escape(package)}-#{escape(version)}"
else
"nix-store -q --refer... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/guix/base/service.rb | Ruby | mit | 300 | master | 695 | class Specinfra::Command::Guix::Base::Service < Specinfra::Command::Linux::Base::Service
class << self
def check_is_enabled(service, level=nil)
"herd status #{escape(service)} | grep 'It is enabled.'"
end
def check_is_running(service)
"herd status #{escape(service)} | grep 'It is started.'"
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/esxi/base/package.rb | Ruby | mit | 300 | master | 335 | class Specinfra::Command::Esxi::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
cmd = "esxcli software vib list | grep -w -- #{escape(package)}"
if version
cmd = "#{cmd} | grep -w -- #{escape(version)}"
end
cmd
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/plamo/base/package.rb | Ruby | mit | 300 | master | 392 | class Specinfra::Command::Plamo::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
cmd = "ls /var/log/packages/#{escape(package)}"
if version
cmd = "#{cmd} && grep -E \"PACKAGE NAME:.+#{escape(package)}-#{escape(version)}\" /var... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/plamo/base/service.rb | Ruby | mit | 300 | master | 349 | class Specinfra::Command::Plamo::Base::Service < Specinfra::Command::Linux::Base::Service
class << self
def check_is_enabled(service, level=3)
# This check is not necessarily detected whether service is enabled or not
# TODO: check rc.inet2 $SERV variable
"test -x /etc/rc.d/init.d/#{escape(servi... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/docker.rb | Ruby | mit | 300 | master | 272 | module Specinfra
module Helper
module Docker
def self.included(klass)
require 'docker' unless defined?(::Docker)
rescue LoadError
fail "Docker client library is not available. Try installing `docker-api' gem."
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/lxc.rb | Ruby | mit | 300 | master | 271 | module Specinfra
module Helper
module Lxc
def self.included(klass)
require 'lxc/extra' unless defined?(::LXC::Extra)
rescue LoadError
fail "LXC client library is not available. Try installing `ruby-lxc' gem."
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/os.rb | Ruby | mit | 300 | master | 254 | require 'specinfra/helper/detect_os'
module Specinfra
module Helper
module Os
def os
property[:os] = Specinfra.configuration.os ?
Specinfra.configuration.os :
Specinfra.backend.os_info
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/properties.rb | Ruby | mit | 300 | master | 279 | require 'specinfra/properties'
module Specinfra
module Helper
module Properties
def property
Specinfra::Properties.instance.properties
end
def set_property(prop)
Specinfra::Properties.instance.properties(prop)
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/configuration.rb | Ruby | mit | 300 | master | 1,377 | module Specinfra
module Helper
module Configuration
def subject
example = RSpec.respond_to?(:current_example) ? RSpec.current_example : self.example
example.metadata[:subject] = described_class
build_configurations
super
end
# You can create a set of configuratio... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os.rb | Ruby | mit | 300 | master | 1,264 | module Specinfra
module Helper
class DetectOs
def self.detect
self.new(Specinfra.backend).detect
end
def initialize(backend)
@backend = backend
end
def run_command(cmd)
@backend.run_command(cmd)
end
def detect
raise NotImplementedError
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/suse.rb | Ruby | mit | 300 | master | 991 | class Specinfra::Helper::DetectOs::Suse < Specinfra::Helper::DetectOs
def detect
if run_command('ls /etc/os-release').success? and run_command('zypper -V').success?
line = run_command('cat /etc/os-release').stdout
if line =~ /ID="?opensuse/
family = 'opensuse'
elsif line =~ /ID="sles"/
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/openbsd.rb | Ruby | mit | 300 | master | 329 | class Specinfra::Helper::DetectOs::Openbsd < Specinfra::Helper::DetectOs
def detect
if ( uname = run_command('uname -sr').stdout ) && uname =~ /OpenBSD/i
if uname =~ /(\d+\.\d+)/
{ :family => 'openbsd', :release => $1 }
else
{ :family => 'openbsd', :release => nil }
end
end
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/nixos.rb | Ruby | mit | 300 | master | 209 | class Specinfra::Helper::DetectOs::Nixos < Specinfra::Helper::DetectOs
def detect
if run_command('ls /var/run/current-system/sw').success?
{ :family => 'nixos', :release => nil }
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/voidlinux.rb | Ruby | mit | 300 | master | 304 | class Specinfra::Helper::DetectOs::Voidlinux < Specinfra::Helper::DetectOs
def detect
if run_command("ls /etc/os-release").success?
line = run_command("cat /etc/os-release").stdout
if line =~ /^ID="void"/
{ :family => 'voidlinux', :release => nil }
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/gentoo.rb | Ruby | mit | 300 | master | 204 | class Specinfra::Helper::DetectOs::Gentoo < Specinfra::Helper::DetectOs
def detect
if run_command('ls /etc/gentoo-release').success?
{ :family => 'gentoo', :release => nil }
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/solaris.rb | Ruby | mit | 300 | master | 681 | class Specinfra::Helper::DetectOs::Solaris < Specinfra::Helper::DetectOs
def detect
if ( uname = run_command('uname -sr').stdout) && uname =~ /SunOS/i
if uname =~ /5.10/
{ :family => 'solaris', :release => 10 }
elsif run_command('grep -q "Oracle Solaris 11" /etc/release').success?
{ :f... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/freebsd.rb | Ruby | mit | 300 | master | 326 | class Specinfra::Helper::DetectOs::Freebsd < Specinfra::Helper::DetectOs
def detect
if ( uname = run_command('uname -sr').stdout ) && uname =~ /FreeBSD/i
if uname =~ /(\d+)\./
{ :family => 'freebsd', :release => $1 }
else
{ :family => 'freebsd', :release => nil }
end
end
en... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper/detect_os/eos.rb | Ruby | mit | 300 | master | 352 | class Specinfra::Helper::DetectOs::Eos < Specinfra::Helper::DetectOs
def detect
# Arista Networks EOS
if run_command('ls /etc/Eos-release').success?
line = run_command('cat /etc/Eos-release').stdout
if line =~ /EOS (\d[\d.]*[A-Z]*)/
release = $1
end
{ :family => 'eos', :release... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.