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 | spec/helper/detect_os/guix_spec.rb | Ruby | mit | 300 | master | 706 | require 'spec_helper'
require 'specinfra/helper/detect_os/guix'
describe Specinfra::Helper::DetectOs::Guix do
guix = Specinfra::Helper::DetectOs::Guix.new(:exec)
it 'Should return guix when Guix is installed.' do
allow(guix).to receive(:run_command) {
CommandResult.new(:stdout => "NAME=\"Guix System\" \n... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | spec/helper/detect_os/debian_spec.rb | Ruby | mit | 300 | master | 5,349 | require 'spec_helper'
require 'specinfra/helper/detect_os/debian'
describe Specinfra::Helper::DetectOs::Debian do
debian = Specinfra::Helper::DetectOs::Debian.new(Specinfra.backend)
it 'Should return debian 7 wheezy is installed.' do
allow(debian).to receive(:run_command).with('cat /etc/debian_version') {
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | spec/helper/detect_os/esxi_spec.rb | Ruby | mit | 300 | master | 709 | require 'spec_helper'
require 'specinfra/helper/detect_os/esxi'
describe Specinfra::Helper::DetectOs::Esxi do
esxi = Specinfra::Helper::DetectOs::Esxi.new(:exec)
it 'Should return esxi when esxi is installed.' do
allow(esxi).to receive(:run_command) {
CommandResult.new(:stdout => 'VMware ESXi 5.0.0 build... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | spec/helper/detect_os/clearlinux_spec.rb | Ruby | mit | 300 | master | 854 | require 'spec_helper'
require 'specinfra/helper/detect_os/clearlinux'
describe Specinfra::Helper::DetectOs::Clearlinux do
clearlinux = Specinfra::Helper::DetectOs::Clearlinux.new(:exec)
it 'Should return clearlinux & release when clearlinux is installed.' do
allow(clearlinux).to receive(:run_command) {
C... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | spec/helper/detect_os/openbsd_spec.rb | Ruby | mit | 300 | master | 1,373 | require 'spec_helper'
require 'specinfra/helper/detect_os/openbsd'
describe Specinfra::Helper::DetectOs::Openbsd do
openbsd = Specinfra::Helper::DetectOs::Openbsd.new(:exec)
it 'Should return (fictional) openbsd 10.11 when OpenBSD 10.11 is installed.' do
allow(openbsd).to receive(:run_command) {
CommandR... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | spec/helper/detect_os/aix_spec.rb | Ruby | mit | 300 | master | 1,993 | require 'spec_helper'
require 'specinfra/helper/detect_os/aix'
describe Specinfra::Helper::DetectOs::Aix do
aix = Specinfra::Helper::DetectOs::Aix.new(:exec)
it 'Should return aix 10.11 powerpc when (fictional) AIX 10.11 is installed.' do
allow(aix).to receive(:run_command).with('uname -s') {
CommandResu... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | spec/helper/detect_os/darwin_spec.rb | Ruby | mit | 300 | master | 1,414 | require 'spec_helper'
require 'specinfra/helper/detect_os/darwin'
describe Specinfra::Helper::DetectOs::Darwin do
darwin = Specinfra::Helper::DetectOs::Darwin.new(Specinfra.backend)
it 'Should return darwin 13.4.0 when Mac OS X 10.9.5 (Mavericks) is installed.' do
allow(darwin).to receive(:run_command) {
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra.rb | Ruby | mit | 300 | master | 1,407 | require 'specinfra/core'
include Specinfra
include Specinfra::Helper::Os
include Specinfra::Helper::Properties
include Specinfra::Helper::HostInventory
module Specinfra
class << self
def command
Specinfra::CommandFactory.instance
end
def backend
type = Specinfra.configuration.backend
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/helper.rb | Ruby | mit | 300 | master | 216 | require 'specinfra/helper/os'
require 'specinfra/helper/docker'
require 'specinfra/helper/lxc'
require 'specinfra/helper/configuration'
require 'specinfra/helper/properties'
require 'specinfra/helper/host_inventory' |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/processor.rb | Ruby | mit | 300 | master | 7,708 | module Specinfra
class Processor
def self.check_service_is_running(service)
cmd = Specinfra.command.get(:check_service_is_running, service)
ret = Specinfra.backend.run_command(cmd)
# In Ubuntu, some services are under upstart and "service foo status" returns
# exit status 0 even though th... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/core.rb | Ruby | mit | 300 | master | 402 | require 'specinfra/version'
require 'specinfra/ext'
require 'specinfra/helper'
require 'specinfra/command'
require 'specinfra/command_factory'
require 'specinfra/command_result'
require 'specinfra/backend'
require 'specinfra/configuration'
require 'specinfra/runner'
require 'specinfra/processor'
module Specinfra
cla... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/properties.rb | Ruby | mit | 300 | master | 235 | require 'singleton'
module Specinfra
class Properties
include Singleton
def initialize
@prop = {}
end
def properties(prop=nil)
if ! prop.nil?
@prop = prop
end
@prop
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command.rb | Ruby | mit | 300 | master | 15,047 | module Specinfra
module Command
end
end
# Module
require 'specinfra/command/module'
require 'specinfra/command/module/service/init'
require 'specinfra/command/module/service/systemd'
require 'specinfra/command/module/service/daemontools'
require 'specinfra/command/module/service/supervisor'
require 'specinfra/comm... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/host_inventory.rb | Ruby | mit | 300 | master | 1,361 | module Specinfra
class HostInventory
KEYS = %w{
memory
ec2
hostname
domain
fqdn
platform
platform_codename
platform_version
filesystem
cpu
virtualization
kernel
block_device
user
group
facter
ohai
mount
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/configuration.rb | Ruby | mit | 300 | master | 1,745 | module Specinfra
module Configuration
class << self
VALID_OPTIONS_KEYS = [
:backend,
:env,
:path,
:shell,
:interactive_shell,
:login_shell,
:pre_command,
:stdout,
:stderr,
:exit_status,
:sudo_path,
:disable_sudo,... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/runner.rb | Ruby | mit | 300 | master | 814 | module Specinfra
class Runner
def self.method_missing(meth, *args)
backend = Specinfra.backend
processor = Specinfra::Processor
if ! os.include?(:family) || os[:family] != 'windows'
if processor.respond_to?(meth)
processor.send(meth, *args)
elsif backend.respon... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/ec2_metadata.rb | Ruby | mit | 300 | master | 2,306 | # -*- coding: utf-8 -*-
module Specinfra
class Ec2Metadata
def initialize(host_inventory)
@host_inventory = host_inventory
@base_uri = 'http://169.254.169.254/latest/meta-data/'
@token_uri = 'http://169.254.169.254/latest/api/token'
@token = ''
@metadata = {}
end
def get
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command_factory.rb | Ruby | mit | 300 | master | 2,492 | class Specinfra::CommandFactory
@@types = nil
def self.instance
self.new(os)
end
def initialize(os_info)
@os_info = os_info
end
def get(meth, *args)
action, resource_type, subaction = breakdown(meth)
method = action
method += "_#{subaction}" if subaction
command_class = create_co... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/backend.rb | Ruby | mit | 300 | master | 550 | require 'specinfra/backend/base'
require 'specinfra/backend/exec'
require 'specinfra/backend/ssh'
require 'specinfra/backend/powershell/script_helper'
require 'specinfra/backend/powershell/command'
require 'specinfra/backend/cmd'
require 'specinfra/backend/docker'
require 'specinfra/backend/dockercli'
require 'specinfr... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command_result.rb | Ruby | mit | 300 | master | 611 | module Specinfra
class CommandResult
attr_reader :stdout, :stderr, :exit_status, :exit_signal
def initialize(args = {})
@stdout = args[:stdout] || ''
@stderr = args[:stderr] || ''
@exit_status = args[:exit_status] || 0
@exit_signal = args[:exit_signal]
end
def success?
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/ext/string.rb | Ruby | mit | 300 | master | 302 | class String
def to_snake_case
self.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr("-", "_").
downcase
end
def to_camel_case
return self if self !~ /_/ && self =~ /[A-Z]+.*/
split('_').map{|e| e.capitalize}.join
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/ext/class.rb | Ruby | mit | 300 | master | 294 | class Class
if !self.method_defined?(:subclasses)
def subclasses
result = []
ObjectSpace.each_object(Class) do |k|
next unless k < self
next if k.respond_to?(:singleton_class?) && k.singleton_class?
result << k
end
result
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base.rb | Ruby | mit | 300 | master | 362 | require 'shellwords'
class Specinfra::Command::Base
class << self
class NotImplementedError < Exception; end
def create
self
end
def escape(target)
str = case target
when Regexp
target.source
else
target.to_s
end
Shel... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/smartos/base/package.rb | Ruby | mit | 300 | master | 416 | class Specinfra::Command::Smartos::Base::Package < Specinfra::Command::Solaris::Base::Package
class << self
def check_is_installed(package, version=nil)
cmd = "pkg_info -qE #{escape(package)}"
if version
cmd = "#{cmd}-#{escape(version)}"
end
cmd
end
def get_version(package... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/smartos/base/file.rb | Ruby | mit | 300 | master | 353 | class Specinfra::Command::Smartos::Base::File < Specinfra::Command::Solaris::Base::File
class << self
def get_md5sum(file)
"/usr/bin/digest -a md5 -v #{escape(file)} | cut -d '=' -f 2 | cut -c 2-"
end
def get_sha256sum(file)
"/usr/bin/digest -a sha256 -v #{escape(file)} | cut -d '=' -f 2... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/smartos/base/service.rb | Ruby | mit | 300 | master | 382 | class Specinfra::Command::Smartos::Base::Service < Specinfra::Command::Solaris::Base::Service
class << self
def check_is_enabled(service, level=nil)
"svcs -l #{escape(service)} 2>/dev/null | grep '^enabled *true$' >/dev/null"
end
def check_is_running(service)
"svcs -Ho state #{escape(service... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base.rb | Ruby | mit | 300 | master | 432 | class Specinfra::Command::Windows::Base
class << self
def create
self
end
private
def create_command(command, using_ps1 = nil)
Backend::PowerShell::Command.new do
using using_ps1 if using_ps1
exec command
end
end
def windows_account account
match = /((... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/hot_fix.rb | Ruby | mit | 300 | master | 612 | class Specinfra::Command::Windows::Base::HotFix < Specinfra::Command::Windows::Base
class << self
def check_is_installed(description, hot_fix_id=nil)
hot_fix_id_match = /(KB\d+)/i.match(description)
hot_fix_id = hot_fix_id_match ? hot_fix_id_match[1] : description if hot_fix_id.nil?
args = [
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/iis_app_pool.rb | Ruby | mit | 300 | master | 2,176 | class Specinfra::Command::Windows::Base::IisAppPool < Specinfra::Command::Windows::Base
class << self
def check_exists(name)
Backend::PowerShell::Command.new do
using 'find_iis_component.ps1'
exec "@(FindIISAppPool -name '#{name}').count -gt 0"
end
end
def check_has_dotnet_ver... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/package.rb | Ruby | mit | 300 | master | 763 | class Specinfra::Command::Windows::Base::Package < Specinfra::Command::Windows::Base
class << self
def check_is_installed(package, version=nil)
version_selection = version.nil? ? "" : "-appVersion '#{version}'"
Backend::PowerShell::Command.new do
using 'find_installed_application.ps1'
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/service.rb | Ruby | mit | 300 | master | 1,561 | class Specinfra::Command::Windows::Base::Service < Specinfra::Command::Windows::Base
class << self
def check_is_installed(service)
Backend::PowerShell::Command.new do
using 'find_service.ps1'
exec "@(FindService -name '#{service}').count -gt 0"
end
end
def check_has_start_mode... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/group.rb | Ruby | mit | 300 | master | 381 | class Specinfra::Command::Windows::Base::Group < Specinfra::Command::Windows::Base
class << self
def check_exists(group)
group_id, domain = windows_account group
Backend::PowerShell::Command.new do
using 'find_group.ps1'
exec "(FindGroup -groupName '#{group_id}'#{domain.nil? ? "" : " -... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/firewall.rb | Ruby | mit | 300 | master | 1,301 | class Specinfra::Command::Windows::Base::Firewall < Specinfra::Command::Windows::Base
class << self
def check_exists(displayName)
cmd = "(Get-NetFirewallRule -DisplayName '#{displayName}') -ne $null"
create_command cmd
end
def check_is_enabled(displayName)
cmd = "((Get-NetFirewallRule -... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/scheduled_task.rb | Ruby | mit | 300 | master | 320 | class Specinfra::Command::Windows::Base::ScheduledTask < Specinfra::Command::Windows::Base
class << self
def check_exists(name)
Backend::PowerShell::Command.new do
using 'find_scheduled_task.ps1'
exec "(FindScheduledTask -name '#{name}').TaskName -eq '\\#{name}'"
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/port.rb | Ruby | mit | 300 | master | 534 | class Specinfra::Command::Windows::Base::Port < Specinfra::Command::Windows::Base
class << self
def check_is_listening(port, options=nil)
Backend::PowerShell::Command.new do
using 'is_port_listening.ps1'
exec "IsPortListening -portNumber #{port}"
end
end
def check_is_listening... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/user.rb | Ruby | mit | 300 | master | 885 | class Specinfra::Command::Windows::Base::User < Specinfra::Command::Windows::Base
class << self
def check_exists(user)
user_id, domain = windows_account user
Backend::PowerShell::Command.new do
using 'find_user.ps1'
exec "(FindUser -userName '#{user_id}'#{domain.nil? ? "" : " -domain '... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/iis_website.rb | Ruby | mit | 300 | master | 2,136 | class Specinfra::Command::Windows::Base::IisWebsite < Specinfra::Command::Windows::Base
class << self
def check_is_enabled(name)
Backend::PowerShell::Command.new do
using 'find_iis_component.ps1'
exec "(FindIISWebsite -name '#{name}').serverAutoStart -eq $true"
end
end
def che... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/registry_key.rb | Ruby | mit | 300 | master | 1,790 | class Specinfra::Command::Windows::Base::RegistryKey < Specinfra::Command::Windows::Base
class << self
REGISTRY_KEY_TYPES = {
:type_string => 'String',
:type_binary => 'Binary',
:type_dword => 'DWord',
:type_qword => 'QWord',
:type_multistring => 'MultiStri... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/feature.rb | Ruby | mit | 300 | master | 482 | class Specinfra::Command::Windows::Base::Feature < Specinfra::Command::Windows::Base
class << self
def check_is_enabled(name, provider)
if provider.nil?
cmd = "@(ListWindowsFeatures -feature #{name}).count -gt 0"
else
cmd = "@(ListWindowsFeatures -feature #{name} -provider #{provider... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/process.rb | Ruby | mit | 300 | master | 993 | class Specinfra::Command::Windows::Base::Process < Specinfra::Command::Windows::Base
class << self
def check_process(process)
Backend::PowerShell::Command.new do
exec "(Get-Process '#{process}') -ne $null"
end
end
def get(process, opts)
column = opts[:format].chomp '='
ca... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/host.rb | Ruby | mit | 300 | master | 960 | class Specinfra::Command::Windows::Base::Host < Specinfra::Command::Windows::Base
class << self
def check_is_resolvable(name, type)
if type == "hosts"
cmd = "@(Select-String -path (Join-Path -Path $($env:windir) -ChildPath 'system32/drivers/etc/hosts') -pattern '#{name}\\b').count -gt 0"
else
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/windows/base/file.rb | Ruby | mit | 300 | master | 3,822 | class Specinfra::Command::Windows::Base::File < Specinfra::Command::Windows::Base
class << self
def check_exists(file)
cmd = %Q!Test-Path -Path "#{file}"!
Backend::PowerShell::Command.new do
exec cmd
end
end
def check_is_file(file)
cmd = item_has_attribute file, 'Archive'
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/suse/base/service.rb | Ruby | mit | 300 | master | 236 | class Specinfra::Command::Suse::Base::Service < Specinfra::Command::Linux::Base::Service
class << self
def check_is_enabled(service, level=3)
"chkconfig --list #{escape(service)} | grep #{level}:on"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/suse/base/package.rb | Ruby | mit | 300 | master | 581 | class Specinfra::Command::Suse::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package,version=nil)
cmd = "rpm -q #{escape(package)}"
if version
cmd = "#{cmd} | grep -w -- #{escape(version)}"
end
cmd
end
alias :check_is_instal... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/debian/v8/service.rb | Ruby | mit | 300 | master | 424 | class Specinfra::Command::Debian::V8::Service < Specinfra::Command::Debian::Base::Service
class << self
include Specinfra::Command::Module::Systemd
def check_is_enabled_under_systemd(service, level=nil)
[
super(service),
"ls /etc/rc[S5].d/S??#{escape(service)} >/dev/null 2>/dev/null"
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/debian/base/service.rb | Ruby | mit | 300 | master | 1,041 | class Specinfra::Command::Debian::Base::Service < Specinfra::Command::Linux::Base::Service
class << self
def create(os_info=nil)
release = (os_info || os)[:release]
if ["testing", "unstable"].include?(release) || release.to_i >= 8
Specinfra::Command::Debian::V8::Service
else
self... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/debian/base/package.rb | Ruby | mit | 300 | master | 1,181 | class Specinfra::Command::Debian::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
escaped_package = escape(package)
if version
cmd = "dpkg-query -f '${Status} ${Version}' -W #{escaped_package} | grep -E '^(install|hold) ok ins... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/debian/base/port.rb | Ruby | mit | 300 | master | 340 | class Specinfra::Command::Debian::Base::Port < Specinfra::Command::Linux::Base::Port
class << self
def create(os_info=nil)
release = (os_info || os)[:release]
if ["testing", "unstable"].include?(release) || release.to_i >= 8
Specinfra::Command::Debian::V8::Port
else
self
en... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/selinux.rb | Ruby | mit | 300 | master | 1,244 | class Specinfra::Command::Linux::Base::Selinux < Specinfra::Command::Base::Selinux
class << self
def check_has_mode(mode, policy = nil)
cmd = ""
# If disabled, then the absence of /etc/selinux/config is sufficient
cmd += "test ! -f /etc/selinux/config || " if mode == "disabled"
# If di... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/lxc_container.rb | Ruby | mit | 300 | master | 551 | class Specinfra::Command::Linux::Base::LxcContainer < Specinfra::Command::Base::LxcContainer
class << self
def check_exists(container)
[
"lxc-ls -1 | grep -w #{escape(container)}",
"virsh -c lxc:/// list --all --name | grep -w '^#{escape(container)}$'"
].join(' || ')
end
def che... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/selinux_module.rb | Ruby | mit | 300 | master | 485 | class Specinfra::Command::Linux::Base::SelinuxModule < Specinfra::Command::Base::SelinuxModule
class << self
def check_is_installed(name, version=nil)
cmd = "semodule -l | grep $'^#{escape(name)}\\t"
cmd += "#{escape(version)}\\t" unless version.nil?
cmd += "'"
cmd
end
def check_... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/bridge.rb | Ruby | mit | 300 | master | 275 | class Specinfra::Command::Linux::Base::Bridge < Specinfra::Command::Base::Bridge
class << self
def check_exists(name)
"ip link show #{name}"
end
def check_has_interface(name, interface)
"brctl show #{name} | grep -o #{interface}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/inventory.rb | Ruby | mit | 300 | master | 834 | class Specinfra::Command::Linux::Base::Inventory < Specinfra::Command::Base::Inventory
class << self
def get_memory
'cat /proc/meminfo'
end
def get_cpu
'cat /proc/cpuinfo'
end
def get_hostname
'hostname -s'
end
def get_domain
'dnsdomainname'
end
def get_... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/fstab.rb | Ruby | mit | 300 | master | 283 | class Specinfra::Command::Linux::Base::Fstab < Specinfra::Command::Base::Fstab
class << self
def check_has_entry(mount_point)
%Q(awk '{if($2=="#{escape(mount_point)}")print}' /etc/fstab | grep -v '^[[:space:]]*#')
end
alias :get_entry :check_has_entry
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/iptables.rb | Ruby | mit | 300 | master | 351 | class Specinfra::Command::Linux::Base::Iptables < Specinfra::Command::Base::Iptables
class << self
def check_has_rule(rule, table=nil, chain=nil)
cmd = "iptables"
cmd += " -t #{escape(table)}" if table
cmd += " -S"
cmd += " #{escape(chain)}" if chain
cmd += " | grep -- #{escape(rule)... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/file.rb | Ruby | mit | 300 | master | 539 | class Specinfra::Command::Linux::Base::File < Specinfra::Command::Base::File
class << self
def check_is_accessible_by_user(file, user, access)
"sudo -u #{user} test -#{access} #{file}"
end
def check_is_immutable(file)
check_attribute(file, 'i')
end
def check_attribute(file, attribute... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/bond.rb | Ruby | mit | 300 | master | 295 | class Specinfra::Command::Linux::Base::Bond < Specinfra::Command::Base::Bond
class << self
def check_exists(name)
"ip link show #{name}"
end
def check_has_interface(name, interface)
"grep -o 'Slave Interface: #{interface}' /proc/net/bonding/#{name}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/kvm_guest.rb | Ruby | mit | 300 | master | 476 | class Specinfra::Command::Linux::Base::KvmGuest < Specinfra::Command::Base::KvmGuest
class << self
def check_exists(guest)
"virsh -c qemu:///system list --all --name | grep -w '^#{escape(guest)}$'"
end
def check_is_running(guest)
"virsh -c qemu:///system list --name | grep -w '^#{escape(guest... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/ip6tables.rb | Ruby | mit | 300 | master | 475 | class Specinfra::Command::Linux::Base::Ip6tables < Specinfra::Command::Base::Ip6tables
class << self
def check_has_rule(rule, table=nil, chain=nil)
cmd = "ip6tables"
cmd += " -t #{escape(table)}" if table
cmd += " -S"
cmd += " #{escape(chain)}" if chain
cmd += " | grep -- #{escape(ru... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/linux/base/interface.rb | Ruby | mit | 300 | master | 1,243 | class Specinfra::Command::Linux::Base::Interface < Specinfra::Command::Base::Interface
class << self
def check_exists(name)
"ip link show #{name}"
end
def get_speed_of(name)
"cat /sys/class/net/#{name}/speed"
end
def get_mtu_of(name)
"cat /sys/class/net/#{name}/mtu"
end
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/clearlinux/base/package.rb | Ruby | mit | 300 | master | 565 | class Specinfra::Command::Clearlinux::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
"swupd bundle-list --quiet | grep -w #{escape(package)}"
end
alias :check_is_installed_by_swupd :check_is_installed
def get_version(package,... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/cumulus/base/service.rb | Ruby | mit | 300 | master | 374 | class Specinfra::Command::Cumuluslinux::Base::Service < Specinfra::Command::Debian::Base::Service
class << self
def check_is_running(service)
"service #{escape(service)} status && service #{escape(service)} status | grep 'running'"
end
end
end
class Specinfra::Command::Cumulusnetworks::Base::Service ... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/cumulus/base/ppa.rb | Ruby | mit | 300 | master | 634 | class Specinfra::Command::Cumuluslinux::Base::Ppa < Specinfra::Command::Debian::Base::Ppa
class << self
def check_exists(package)
%Q{find /etc/apt/ -name \*.list | xargs grep -o "deb +http://repo.cumulusnetworks.com/#{to_apt_line_uri(package)}"}
end
def check_is_enabled(package)
%Q{find /etc/... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/sles/v11/user.rb | Ruby | mit | 300 | master | 405 | class Specinfra::Command::Sles::V11::User < Specinfra::Command::Sles::Base::User
class << self
def get_minimum_days_between_password_change(user)
"chage -l #{escape(user)} | sed -n 's/^Minimum://p' | sed 's|^[[:blank:]]*||g'"
end
def get_maximum_days_between_password_change(user)
"chage -l #{... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/sles/base/service.rb | Ruby | mit | 300 | master | 276 | class Specinfra::Command::Sles::Base::Service < Specinfra::Command::Suse::Base::Service
class << self
def create(os_info=nil)
if (os_info || os)[:release].to_i < 12
self
else
Specinfra::Command::Sles::V12::Service
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/poky/base/package.rb | Ruby | mit | 300 | master | 778 | class Specinfra::Command::Poky::Base::Package < Specinfra::Command::Linux::Base::Package
class << self
def check_is_installed(package, version=nil)
package_escaped = escape(package)
cmd = "opkg status #{package_escaped} | grep -E '^Version|(user|ok) installed$'"
cmd = "#{cmd} | grep -E #{escape(... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/fedora/base/service.rb | Ruby | mit | 300 | master | 282 | class Specinfra::Command::Fedora::Base::Service < Specinfra::Command::Redhat::Base::Service
class << self
def create(os_info=nil)
if (os_info || os)[:release].to_i < 15
self
else
Specinfra::Command::Fedora::V15::Service
end
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/package.rb | Ruby | mit | 300 | master | 577 | class Specinfra::Command::Openbsd::Base::Package < Specinfra::Command::Base::Package
class << self
def check_is_installed(package, version=nil)
if version
"pkg_info -a | cut -d ' ' -f 1 | grep #{escape(package)}-#{escape(version)}"
else
"pkg_info -a | cut -d ' ' -f 1 | grep #{escape(... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/fstab.rb | Ruby | mit | 300 | master | 285 | class Specinfra::Command::Openbsd::Base::Fstab < Specinfra::Command::Base::Fstab
class << self
def check_has_entry(mount_point)
%Q(awk '{if($2=="#{escape(mount_point)}")print}' /etc/fstab | grep -v '^[[:space:]]*#')
end
alias :get_entry :check_has_entry
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/routing_table.rb | Ruby | mit | 300 | master | 272 | class Specinfra::Command::Openbsd::Base::RoutingTable < Specinfra::Command::Base::RoutingTable
class << self
def check_has_entry(destination)
"route -n show -gateway | egrep '^#{destination}' | head -1"
end
alias :get_entry :check_has_entry
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/bridge.rb | Ruby | mit | 300 | master | 271 | class Specinfra::Command::Openbsd::Base::Bridge < Specinfra::Command::Base::Bridge
class << self
def check_exists(name)
"ifconfig #{name}"
end
def check_has_interface(name, interface)
"ifconfig #{name} | grep -o #{interface}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/inventory.rb | Ruby | mit | 300 | master | 530 | class Specinfra::Command::Openbsd::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 | ' +
'awk -v h=`hostname -s` \'$1 ~ h { su... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/bond.rb | Ruby | mit | 300 | master | 267 | class Specinfra::Command::Openbsd::Base::Bond < Specinfra::Command::Base::Bond
class << self
def check_exists(name)
"ifconfig #{name}"
end
def check_has_interface(name, interface)
"ifconfig #{name} | grep -o #{interface}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/file.rb | Ruby | mit | 300 | master | 1,123 | class Specinfra::Command::Openbsd::Base::File < Specinfra::Command::Base::File
class << self
def get_md5sum(file)
"cksum -qa md5 #{escape(file)} | cut -d ' ' -f 1"
end
def get_sha256sum(file)
"cksum -qa sha256 #{escape(file)} | cut -d ' ' -f 1"
end
def check_is_linked_to(link, target... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/interface.rb | Ruby | mit | 300 | master | 2,026 | class Specinfra::Command::Openbsd::Base::Interface < Specinfra::Command::Base::Interface
class << self
def check_exists(name)
"ifconfig #{name}"
end
def get_speed_of(name)
"ifconfig #{name} | grep 'media\:' | perl -pe 's|.*media\:.*\\((.*?)\\)|\\1|'"
end
def check_has_ipv4_address(in... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/host.rb | Ruby | mit | 300 | master | 687 | class Specinfra::Command::Openbsd::Base::Host < Specinfra::Command::Base::Host
class << self
def get_ipaddress(name)
# getent hosts will return both the ipv6 and ipv4 record.
# this will only pick the first one. (Linux behavior)
"getent hosts #{escape(name)} | awk '{print $1; exit}'"
end
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/user.rb | Ruby | mit | 300 | master | 401 | class Specinfra::Command::Openbsd::Base::User < Specinfra::Command::Base::User
class << self
def check_has_login_shell(user, path_to_shell)
"getent passwd #{escape(user)} | cut -f 7 -d ':' | grep #{escape(path_to_shell)}"
end
def check_has_home_directory(user, path_to_home)
"getent passwd #{e... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/mail_alias.rb | Ruby | mit | 300 | master | 311 | class Specinfra::Command::Openbsd::Base::MailAlias < Specinfra::Command::Base::MailAlias
class << self
def check_is_aliased_to(recipient, target)
target = %Q{([[:space:]]|,)["']?#{escape(target)}["']?(,|$)}
"egrep ^#{escape(recipient)}:.*#{escape(target)} /etc/mail/aliases"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/port.rb | Ruby | mit | 300 | master | 463 | class Specinfra::Command::Openbsd::Base::Port < Specinfra::Command::Base::Port
class << self
def check_is_listening(port, opts={})
protocol = opts[:protocol]
case protocol
when 'tcp'
return "netstat -nat -f inet | egrep '(tcp.*.#{port}.*LISTEN$)'"
when 'udp'
return "netstat... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/base/service.rb | Ruby | mit | 300 | master | 461 | class Specinfra::Command::Openbsd::Base::Service < Specinfra::Command::Base::Service
class << self
def create(os_info=nil)
if (os_info || os)[:release].to_f < 5.7
self
else
Specinfra::Command::Openbsd::V57::Service
end
end
def check_is_enabled(service, level=nil)
"... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/openbsd/v57/service.rb | Ruby | mit | 300 | master | 748 | class Specinfra::Command::Openbsd::V57::Service < Specinfra::Command::Openbsd::Base::Service
class << self
def check_is_enabled(service, level=nil)
"rcctl get #{escape(service)} status"
end
def check_is_running(service)
"rcctl check #{escape(service)}"
end
def enable(service)
"... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/group.rb | Ruby | mit | 300 | master | 302 | class Specinfra::Command::Aix::Base::Group < Specinfra::Command::Base::Group
class << self
def check_exists(group)
"lsgroup #{escape(group)}"
end
def check_has_gid(group, gid)
"lsgroup -a id #{escape(group)} | cut -f 2 -d '=' | grep -w -- #{escape(gid)}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/package.rb | Ruby | mit | 300 | master | 322 | class Specinfra::Command::Aix::Base::Package < Specinfra::Command::Base::Package
class << self
def check_is_installed(package, version=nil)
if version
"lslpp -L #{escape(package)} | awk '{print $2}' | grep -w -- #{version}"
else
"lslpp -L #{escape(package)}"
end
end
end
en... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/inventory.rb | Ruby | mit | 300 | master | 1,042 | class Specinfra::Command::Aix::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
# This is emulating the dnsdomainname command in Linux
# Req... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/file.rb | Ruby | mit | 300 | master | 631 | class Specinfra::Command::Aix::Base::File < Specinfra::Command::Base::File
class << self
def check_is_accessible_by_user(file, user, access)
"su -s sh -c \"test -#{access} #{file}\" #{user}"
end
def check_has_mode(file, mode)
"find #{file} -prune -perm #{mode} | grep ^#{file}$"
end
d... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/host.rb | Ruby | mit | 300 | master | 557 | class Specinfra::Command::Aix::Base::Host < Specinfra::Command::Base::Host
class << self
def check_is_resolvable(name, type)
if type == "dns"
%Q[lookup=$(nslookup -timeout=1 #{escape(name)} | grep -A1 'Name:' | grep Address | awk -F': ' '{print $2}'); if [ "$lookup" ]; then $(exit 0); else $(exit 1)... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/service.rb | Ruby | mit | 300 | master | 308 | class Specinfra::Command::Aix::Base::Service < Specinfra::Command::Base::Service
class << self
def check_is_enabled(service,level=nil)
"lssrc -s #{escape(service)} | grep active"
end
def check_is_running(service)
"ps -ef | grep -v grep | grep #{escape(service)}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/user.rb | Ruby | mit | 300 | master | 592 | class Specinfra::Command::Aix::Base::User < Specinfra::Command::Base::User
class << self
def check_belongs_to_group(user, group)
"lsuser -a groups #{escape(user)} | awk -F'=' '{print $2}'| sed -e 's/,/ /g' |grep -w -- #{escape(group)}"
end
def check_has_login_shell(user, path_to_shell)
"lsus... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/aix/base/port.rb | Ruby | mit | 300 | master | 250 | class Specinfra::Command::Aix::Base::Port < Specinfra::Command::Base::Port
class << self
def check_is_listening(port, options={})
regexp = "*.#{port} "
"netstat -an -f inet | awk '{print $4}' | grep -- #{regexp}"
end
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/user.rb | Ruby | mit | 300 | master | 3,469 | class Specinfra::Command::Base::User < Specinfra::Command::Base
class << self
def check_exists(user)
"id #{escape(user)}"
end
def check_belongs_to_group(user, group)
"id #{escape(user)} | sed 's/ context=.*//g' | cut -f 4 -d '=' | grep -- #{escape(group)}"
end
def check_belongs_to_pr... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/cron.rb | Ruby | mit | 300 | master | 584 | class Specinfra::Command::Base::Cron < Specinfra::Command::Base
class << self
def check_has_entry(user, entry)
entry_escaped = entry.gsub(/\\/, '\\\\\\').gsub(/\*/, '\\*').gsub(/\[/, '\\[').gsub(/\]/, '\\]')
grep_command = "grep -v '^[[:space:]]*#' | grep -- ^#{escape(entry_escaped)}$"
if user.n... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/port.rb | Ruby | mit | 300 | master | 381 | class Specinfra::Command::Base::Port < Specinfra::Command::Base
class << self
def check_is_listening(port, options={})
pattern = ":#{port} "
pattern = " #{options[:local_address]}#{pattern}" if options[:local_address]
pattern = "^#{options[:protocol]} .*#{pattern}" if options[:protocol]
"n... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/package.rb | Ruby | mit | 300 | master | 2,355 | class Specinfra::Command::Base::Package < Specinfra::Command::Base
class << self
def check_is_installed_by_gem(name, version=nil, gem_binary="gem")
gem_installed_command(gem_binary, name, version)
end
def check_is_installed_by_td_agent_gem(name, version=nil)
gem_installed_command("/usr/sbin/t... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/file.rb | Ruby | mit | 300 | master | 5,268 | class Specinfra::Command::Base::File < Specinfra::Command::Base
class << self
def check_is_file(file)
"test -f #{escape(file)}"
end
def check_is_directory(directory)
"test -d #{escape(directory)}"
end
def check_is_pipe(file)
"test -p #{escape(file)}"
end
def check_is_s... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/host.rb | Ruby | mit | 300 | master | 1,357 | class Specinfra::Command::Base::Host < Specinfra::Command::Base
class << self
def check_is_resolvable(name, type)
if type == "dns"
%Q[lookup=$(nslookup -timeout=1 #{escape(name)} | grep -A1 'Name:' | grep Address | awk -F': ' '{print $2}'); if [ "$lookup" ]; then $(exit 0); else $(exit 1); fi]
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/mail_alias.rb | Ruby | mit | 300 | master | 535 | class Specinfra::Command::Base::MailAlias < Specinfra::Command::Base
class << self
def check_is_aliased_to(mail_alias, recipient)
## if the recipient contains pipes escape them
## or egrep will interpret it as an OR
recipient = recipient.gsub(/\|/, '\|')
recipient = "[[:space:]]([\"']?)#{r... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/routing_table.rb | Ruby | mit | 300 | master | 297 | class Specinfra::Command::Base::RoutingTable < Specinfra::Command::Base
class << self
def check_has_entry(destination)
if destination == "default"
destination = "0.0.0.0/0"
end
"ip route show #{destination}"
end
alias :get_entry :check_has_entry
end
end |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/service.rb | Ruby | mit | 300 | master | 643 | class Specinfra::Command::Base::Service < Specinfra::Command::Base
class << self
include Specinfra::Command::Module::Service::Init
include Specinfra::Command::Module::Service::Systemd
include Specinfra::Command::Module::Service::Daemontools
include Specinfra::Command::Module::Service::Supervisor
i... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/group.rb | Ruby | mit | 300 | master | 1,327 | class Specinfra::Command::Base::Group < Specinfra::Command::Base
class << self
def check_exists(group)
"getent group #{escape(group)}"
end
def check_has_gid(group, gid)
"getent group #{escape(group)} | cut -f 3 -d ':' | grep -w -- #{escape(gid)}"
end
def check_is_system_group(group)
... |
github | mizzy/specinfra | https://github.com/mizzy/specinfra | lib/specinfra/command/base/process.rb | Ruby | mit | 300 | master | 542 | class Specinfra::Command::Base::Process < Specinfra::Command::Base
class << self
def get(process, opts)
"ps -C #{escape(process)} -o #{opts[:format]} | head -1"
end
def count(process)
"ps aux | grep -w -- #{escape(process)} | grep -v grep | wc -l"
end
def check_is_running(process)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.