]> gitweb.fluxo.info Git - puppet-nodo.git/commitdiff
Feat: adds nodo::subsystem::modprobe::module and improves nodo::subsystem::sensors
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 5 Jul 2024 15:34:18 +0000 (12:34 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 5 Jul 2024 15:34:18 +0000 (12:34 -0300)
manifests/subsystem/modprobe/module.pp [new file with mode: 0644]
manifests/subsystem/sensors.pp

diff --git a/manifests/subsystem/modprobe/module.pp b/manifests/subsystem/modprobe/module.pp
new file mode 100644 (file)
index 0000000..21ec4ed
--- /dev/null
@@ -0,0 +1,35 @@
+#
+# Handles Linux kernel module loading.
+#
+# Module loading is implemented both for SysV and systemd based systems, to
+# ensure this module is managed in either case.
+#
+# It also remains to be tested whether _both_ /etc/modules and /etc/modules-load.d
+# are processed by recent systemd-based Debian systems; or if there are
+# inconsistencies between the implementation and the documentation:
+#
+#   https://wiki.debian.org/Modules#Automatic_loading_of_modules
+#
+# Anyway, having this configuration in both places does not seem to hurt (much).
+#
+# Check also https://wiki.archlinux.org/title/Kernel_module#Automatic_module_loading
+#            https://unix.stackexchange.com/questions/189670/whats-the-difference-of-etc-modules-load-d-and-etc-modules
+define nodo::subsystem::modprobe::module(
+  $ensure = 'present',
+){
+  # Drivetemp module loading for systems using SysV -- /etc/modules - modules(5)
+  file_line { "etc-modules-${name}":
+    path   => "/etc/modules",
+    line   => "${name}",
+    ensure => $ensure,
+  }
+
+  # Drivetemp module loading using systemd's /etc/modules-load.d/ - modules-load.d(5)
+  file { "/etc/modules-load.d/${name}.conf":
+    ensure  => $ensure,
+    owner   => root,
+    group   => root,
+    mode    => '0644',
+    content => "${name}\n",
+  }
+}
index caa99ef859f5c14a39816e052d046f28302fd99e..9b50d9b70595473d54dc296bee111c08395b0a12 100644 (file)
@@ -3,7 +3,7 @@ class nodo::subsystem::sensors {
   # SMART monitoring
   #
 
-  $smartmontools = lookup('nodo::smartmontools', undef, undef, true)
+  $smartmontools = lookup('nodo::sensors::smartmontools', undef, undef, true)
 
   if $smartmontools == true {
     class { 'smartmontools': }
@@ -13,17 +13,19 @@ class nodo::subsystem::sensors {
   # LM Sensors
   #
 
+  $lm_sensors = lookup('nodo::sensors::lm_sensors', undef, undef, true)
+
   package { [
     'lm-sensors',
   ]:
-    ensure => present,
+    ensure => $lm_sensors,
   }
 
   #
   # hddtemp
   #
 
-  # Deprecated in favor of drivetemp
+  # Deprecated in favor of drivetemp:
   # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1002484
   package { [
     'hddtemp',
@@ -39,43 +41,14 @@ class nodo::subsystem::sensors {
   #
   # drivetemp
   #
-  # References: https://www.baeldung.com/linux/hdd-ssd-temperature
-  #             https://askubuntu.com/questions/1426482/tool-to-monitor-hdd-temperature-in-ubuntu-server-22-04
-  #             https://wiki.archlinux.org/title/Lm_sensors#S.M.A.R.T._drive_temperature
-  #             https://github.com/philipl/drivetemp
-  #
-  # We'll implement drive temp module loading both for SysV and systemd based
-  # systems, to ensure this module is managed in either case.
-  #
-  # It also remains to be tested whether _both_ /etc/modules and /etc/modules-load.d
-  # are processed by recent systemd-based Debian systems; or if there are
-  # inconsistencies between the implementation and the documentation:
-  #
-  #   https://wiki.debian.org/Modules#Automatic_loading_of_modules
-  #
-  # Anyway, having this configuration in both places does not seem to hurt (much).
-  #
-  # Check also https://wiki.archlinux.org/title/Kernel_module#Automatic_module_loading
-  #            https://unix.stackexchange.com/questions/189670/whats-the-difference-of-etc-modules-load-d-and-etc-modules
-  #
-  # FIXME: this logic should be moved to a nodo::subsystem::modprobe::module definition.
-  #
+  # https://www.baeldung.com/linux/hdd-ssd-temperature
+  # https://askubuntu.com/questions/1426482/tool-to-monitor-hdd-temperature-in-ubuntu-server-22-04
+  # https://wiki.archlinux.org/title/Lm_sensors#S.M.A.R.T._drive_temperature
+  # https://github.com/philipl/drivetemp
 
-  $drivetemp = lookup('nodo::drivetemp', undef, undef, 'present')
+  $drivetemp = lookup('nodo::sensors::drivetemp', undef, undef, 'present')
 
-  # Drivetemp module loading for systems using SysV -- /etc/modules - modules(5)
-  file_line { 'etc-modules-drivetemp':
-    path   => "/etc/modules",
-    line   => "drivetemp",
+  nodo::subsystem::modprobe::module { 'drivetemp':
     ensure => $drivetemp,
   }
-
-  # Drivetemp module loading using systemd's /etc/modules-load.d/ - modules-load.d(5)
-  file { '/etc/modules-load.d/drivetemp.conf':
-    ensure  => $drivetemp,
-    owner   => root,
-    group   => root,
-    mode    => '0644',
-    content => "drivetemp\n",
-  }
 }