Class: Inspec::Resources::KernelModule
- Inherits:
- 
      Object
      
        - Object
- Inspec::Resources::KernelModule
 
- Defined in:
- lib/resources/kernel_module.rb
Instance Method Summary collapse
- #blacklisted? ⇒ Boolean
- #disabled? ⇒ Boolean
- 
  
    
      #initialize(modulename = nil)  ⇒ KernelModule 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of KernelModule. 
- #loaded? ⇒ Boolean
- #to_s ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(modulename = nil) ⇒ KernelModule
Returns a new instance of KernelModule.
| 40 41 42 43 44 | # File 'lib/resources/kernel_module.rb', line 40 def initialize(modulename = nil) @module = modulename # this resource is only supported on Linux return skip_resource 'The `kernel_parameter` resource is not supported on your OS.' if !inspec.os.linux? end | 
Instance Method Details
#blacklisted? ⇒ Boolean
| 67 68 69 | # File 'lib/resources/kernel_module.rb', line 67 def blacklisted? !modprobe_output.match(/^blacklist\s+#{@module}/).nil? || disabled_via_bin_true? || disabled_via_bin_false? end | 
#disabled? ⇒ Boolean
| 63 64 65 | # File 'lib/resources/kernel_module.rb', line 63 def disabled? !modprobe_output.match(%r{^install\s+#{@module}\s+/(s?)bin/(true|false)}).nil? end | 
#loaded? ⇒ Boolean
| 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # File 'lib/resources/kernel_module.rb', line 46 def loaded? if inspec.os.redhat? || inspec.os.name == 'fedora' lsmod_cmd = '/sbin/lsmod' else lsmod_cmd = 'lsmod' end # get list of all modules cmd = inspec.command(lsmod_cmd) return false if cmd.exit_status != 0 # check if module is loaded re = Regexp.new('^'+Regexp.quote(@module)+'\s') found = cmd.stdout.match(re) !found.nil? end | 
#to_s ⇒ Object
| 76 77 78 | # File 'lib/resources/kernel_module.rb', line 76 def to_s "Kernel Module #{@module}" end | 
#version ⇒ Object
| 71 72 73 74 | # File 'lib/resources/kernel_module.rb', line 71 def version cmd = inspec.command("#{modinfo_cmd_for_os} -F version #{@module}") cmd.exit_status.zero? ? cmd.stdout.delete("\n") : nil end |