Class: KernelModule
- Inherits:
-
Object
- Object
- KernelModule
- Defined in:
- lib/resources/kernel_module.rb
Overview
author: Christoph Hartmann author: Dominik Richter license: All rights reserved
Instance Method Summary collapse
-
#initialize(modulename = nil) ⇒ KernelModule
constructor
A new instance of KernelModule.
- #loaded? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(modulename = nil) ⇒ KernelModule
Returns a new instance of KernelModule.
15 16 17 18 19 20 |
# File 'lib/resources/kernel_module.rb', line 15 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
#loaded? ⇒ Boolean
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/resources/kernel_module.rb', line 22 def loaded? # default lsmod command lsmod_cmd = 'lsmod' # special care for CentOS 5 and sudo lsmod_cmd = '/sbin/lsmod' if inspec.os[:family] == 'centos' && inspec.os[:release].to_i == 5 # 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
38 39 40 |
# File 'lib/resources/kernel_module.rb', line 38 def to_s "Kernel Module #{@module}" end |