Class: SpecInfra::Command::RedHat

Inherits:
Linux
  • Object
show all
Defined in:
lib/specinfra/command/redhat.rb

Direct Known Subclasses

Fedora, RedHat7

Instance Method Summary collapse

Methods inherited from Linux

#check_attribute, #check_container, #check_container_running, #check_immutable, #check_iptables_rule, #check_ipv4_address, #check_kernel_module_loaded, #check_selinux, #check_zfs, #get_interface_speed_of

Methods inherited from Base

#check_authorized_key, #check_belonging_group, #check_container, #check_cotainer_running, #check_cron_entry, #check_directory, #check_file, #check_file_checksum, #check_file_contain, #check_file_contain_lines, #check_file_contain_with_fixed_strings, #check_file_contain_with_regexp, #check_file_contain_within, #check_file_md5checksum, #check_file_sha256checksum, #check_gid, #check_group, #check_grouped, #check_home_directory, #check_immutable, #check_installed_by_cpan, #check_installed_by_gem, #check_installed_by_npm, #check_installed_by_pear, #check_installed_by_pecl, #check_installed_by_pip, #check_ipfilter_rule, #check_ipnat_rule, #check_iptables_rule, #check_ipv4_address, #check_kernel_module_loaded, #check_link, #check_listening, #check_listening_with_protocol, #check_login_shell, #check_mail_alias, #check_mode, #check_monitored_by_god, #check_monitored_by_monit, #check_mounted, #check_owner, #check_primary_group, #check_process, #check_process_count, #check_reachable, #check_resolvable, #check_routing_table, #check_running, #check_running_under_supervisor, #check_running_under_upstart, #check_selinux, #check_service_installed, #check_service_start_mode, #check_socket, #check_svcprop, #check_svcprops, #check_uid, #check_user, #check_zfs, #escape, #get_file_content, #get_file_mtime, #get_file_size, #get_ipaddress_of_host, #get_mode, #get_process

Instance Method Details

#check_access_by_user(file, user, access) ⇒ Object



4
5
6
7
# File 'lib/specinfra/command/redhat.rb', line 4

def check_access_by_user(file, user, access)
  # Redhat-specific
  "runuser -s /bin/sh -c \"test -#{access} #{file}\" #{user}"
end

#check_belonging_primary_group(user, group) ⇒ Object



9
10
11
# File 'lib/specinfra/command/redhat.rb', line 9

def check_belonging_primary_group(user, group)
  "id -gn #{escape(user)}| grep ^#{escape(group)}$"
end

#check_enabled(service, level = 3) ⇒ Object



13
14
15
# File 'lib/specinfra/command/redhat.rb', line 13

def check_enabled(service, level=3)
  "chkconfig --list #{escape(service)} | grep #{level}:on"
end

#check_installed(package, version = nil) ⇒ Object Also known as: check_installed_by_rpm



25
26
27
28
29
30
31
# File 'lib/specinfra/command/redhat.rb', line 25

def check_installed(package,version=nil)
  cmd = "rpm -q #{escape(package)}"
  if version
    cmd = "#{cmd} | grep -w -- #{escape(version)}"
  end
  cmd
end

#check_yumrepo(repository) ⇒ Object



17
18
19
# File 'lib/specinfra/command/redhat.rb', line 17

def check_yumrepo(repository)
  "yum repolist all -C | grep ^#{escape(repository)}"
end

#check_yumrepo_enabled(repository) ⇒ Object



21
22
23
# File 'lib/specinfra/command/redhat.rb', line 21

def check_yumrepo_enabled(repository)
  "yum repolist all -C | grep ^#{escape(repository)} | grep enabled"
end

#get_package_version(package, opts = nil) ⇒ Object



39
40
41
# File 'lib/specinfra/command/redhat.rb', line 39

def get_package_version(package, opts=nil)
  "rpm -qi #{package} | grep Version | awk '{print $3}'"
end

#install(package) ⇒ Object



35
36
37
# File 'lib/specinfra/command/redhat.rb', line 35

def install(package)
  cmd = "yum -y install #{package}"
end