Commit ab9e385f authored by Marcel Haerry's avatar Marcel Haerry
Browse files

refactor module to the new standard

parent f2c007f2
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
# #
class modprobe { class modprobe {
file{'/etc/modprobe.conf': file{'/etc/modprobe.conf':
source => [ source => [
"puppet://$server/site-modprobe/$fqdn/modprobe.conf", "puppet:///modules/site-modprobe/$fqdn/modprobe.conf",
"puppet://$server/site-modprobe/$virtual/modprobe.conf", "puppet:///modules/site-modprobe/$virtual/modprobe.conf",
"puppet://$server/site-modprobe/$operatingsystem/modprobe.conf", "puppet:///modules/site-modprobe/$operatingsystem/modprobe.conf",
"puppet://$server/site-modprobe/modprobe.conf", "puppet:///modules/site-modprobe/modprobe.conf",
"puppet://$server/modprobe/$virtual/modprobe.conf", "puppet:///modules/modprobe/$virtual/modprobe.conf",
"puppet://$server/modprobe/$operatingsystem/modprobe.conf", "puppet:///modules/modprobe/$operatingsystem/modprobe.conf",
"puppet://$server/modprobe/modprobe.conf", "puppet:///modules/modprobe/modprobe.conf",
], ],
owner => root, group => 0, mode => 0644; owner => root, group => 0, mode => 0644;
} }
} }
define modprobe::kern_module( define modprobe::kern_module(
$ensure = 'present' $ensure = 'present'
){ ){
case $operatingsystem { case $operatingsystem {
debian,ubuntu: {
$modulesfile = '/etc/modules'
}
default: {
$modulesfile = '/etc/rc.modules'
}
}
case $ensure {
present: {
exec{"insert_module_$name":
command => "/bin/echo '/sbin/modprobe $name' >> $modulesfile",
unless => "/bin/grep -qFx '/sbin/modprobe $name' $modulesfile",
}
exec{"/sbin/modprobe $name":
unless => "/bin/grep -q '^$name ' /proc/modules"
}
case $operatingsystem {
debian,ubuntu: { debian,ubuntu: {
$modulesfile = '/etc/modules' Exec["insert_module_$name"]{
} command => "/bin/echo '$name' >> $modulesfile",
default: { unless => "/bin/grep -qFx '$name' $modulesfile",
$modulesfile = '/etc/rc.modules' }
} }
}
} }
case $ensure { absent: {
present: { exec{"/sbin/modprobe -r $name":
exec{"insert_module_$name": onlyif => "/bin/grep -q '^$name ' /proc/modules"
command => "/bin/echo '/sbin/modprobe $name' >> $modulesfile", }
unless => "/bin/grep -qFx '/sbin/modprobe $name' $modulesfile", exec{"remove_module_$name":
} command => "/bin/sed -i '/^\\/sbin\\/modprobe $name$/d' $modulesfile",
exec{"/sbin/modprobe $name": onlyif => "/bin/grep -qFx '/sbin/modprobe $name' $modulesfile",
unless => "/bin/grep -q '^$name ' /proc/modules" }
} case $operatingsystem {
case $operatingsystem { debian,ubuntu: {
debian,ubuntu: { Exec["remove_module_$name"]{
Exec["insert_module_$name"]{ command => "/bin/sed -i '/^$name$/d' $modulesfile",
command => "/bin/echo '$name' >> $modulesfile", onlyif => "/bin/grep -qFx '$name' $modulesfile",
unless => "/bin/grep -qFx '$name' $modulesfile", }
}
}
}
}
absent: {
exec{"/sbin/modprobe -r $name":
onlyif => "/bin/grep -q '^$name ' /proc/modules"
}
exec{"remove_module_$name":
command => "/bin/sed -i '/^\\/sbin\\/modprobe $name$/d' $modulesfile",
onlyif => "/bin/grep -qFx '/sbin/modprobe $name' $modulesfile",
}
case $operatingsystem {
debian,ubuntu: {
Exec["remove_module_$name"]{
command => "/bin/sed -i '/^$name$/d' $modulesfile",
onlyif => "/bin/grep -qFx '$name' $modulesfile",
}
}
}
}
default: {
fail("Unknown ensure value '$ensure' for modprobe::kern_module!")
} }
}
}
default: {
fail("Unknown ensure value '$ensure' for modprobe::kern_module!")
} }
}
} }
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