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

refactor module to the new standard

parent f2c007f2
......@@ -12,16 +12,16 @@
#
class modprobe {
file{'/etc/modprobe.conf':
source => [
"puppet://$server/site-modprobe/$fqdn/modprobe.conf",
"puppet://$server/site-modprobe/$virtual/modprobe.conf",
"puppet://$server/site-modprobe/$operatingsystem/modprobe.conf",
"puppet://$server/site-modprobe/modprobe.conf",
"puppet://$server/modprobe/$virtual/modprobe.conf",
"puppet://$server/modprobe/$operatingsystem/modprobe.conf",
"puppet://$server/modprobe/modprobe.conf",
],
owner => root, group => 0, mode => 0644;
}
file{'/etc/modprobe.conf':
source => [
"puppet:///modules/site-modprobe/$fqdn/modprobe.conf",
"puppet:///modules/site-modprobe/$virtual/modprobe.conf",
"puppet:///modules/site-modprobe/$operatingsystem/modprobe.conf",
"puppet:///modules/site-modprobe/modprobe.conf",
"puppet:///modules/modprobe/$virtual/modprobe.conf",
"puppet:///modules/modprobe/$operatingsystem/modprobe.conf",
"puppet:///modules/modprobe/modprobe.conf",
],
owner => root, group => 0, mode => 0644;
}
}
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: {
$modulesfile = '/etc/modules'
}
default: {
$modulesfile = '/etc/rc.modules'
Exec["insert_module_$name"]{
command => "/bin/echo '$name' >> $modulesfile",
unless => "/bin/grep -qFx '$name' $modulesfile",
}
}
}
}
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: {
Exec["insert_module_$name"]{
command => "/bin/echo '$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!")
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!")
}
}
}
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