Commit 17fbc5d6 authored by Marcel Haerry's avatar Marcel Haerry
Browse files

added possiblity to (un)load modules (permamently)

parent 5bf3dd9b
# manifest/defines.pp
# taken from: http://reductivelabs.com/trac/puppet/wiki/Recipes/KernelModules
define kern_module(
$ensure = 'present'
){
# chosse and load default file
$modulesfile = $operatingsystem ? {
debian => "/etc/modules",
redhat => "/etc/rc.modules"
}
include modprobe::loadfile
case $ensure {
present: {
exec{"insert_module_${name}":
command => "/bin/echo '/sbin/modprobe ${name}' >> '${modulesfile}' ",
unless => "/bin/grep -qFx '${name}' '${modulesfile}'"
}
case $operatingsystem {
debian,ubuntu: {
Exec["insert_module_${name}"]{
command => "/bin/echo '${name}' >> '${modulesfile}'",
}
}
}
exec{"/sbin/modprobe ${name}":
unless => "/bin/grep -q '^${name} ' '/proc/modules'"
}
}
absent: {
exec{"/sbin/modprobe -r ${name}":
onlyif => "/bin/grep -q '^${name} ' '/proc/modules'"
}
exec { "remove_module_${name}":
command => "/usr/bin/perl -ni -e 'print unless /^\\Q/sbin/modprobe ${name}\\E\$/' '${modulesfile}'",
onlyif => "/bin/grep -q '^/sbin/modprobe ${name}' '${modulesfile}'",
}
case $operatingsystem {
debian,ubuntu: {
Exec["remove_module_${name}"]{
command => "/usr/bin/perl -ni -e 'print unless /^\\Q${name}\\E\$/' '${modulesfile}'",
onlyif => "/bin/grep -qFx '${name}' '${modulesfile}'",
}
}
}
}
default: {
fail("unknown ensure value ${ensure} to modprobe ${name} on ${fqdn}")
}
}
}
......@@ -11,7 +11,7 @@
# the Free Software Foundation.
#
# modules_dir { "modprobe": }
import 'defines.pp'
class modprobe {
file{"/etc/modprobe.conf":
......
# manifests/loadfile.pp
class modprobe::loadfile {
case $operatingsystem {
redhat,centos,fedora: {
file{'/etc/rc.modules':
ensure => file,
mode => 755
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment