Filippo Giunchedi has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/371642 )

Change subject: udev: new module
......................................................................

udev: new module

Swift requires custom udev rules both in production and labs, refactor
the duplicated code into a generic udev module.

Change-Id: I85bbbbdc3b5509eb078be867a1baa2bf54eca830
---
M modules/profile/manifests/swift/storage/labs.pp
M modules/swift/manifests/storage.pp
R modules/swift/templates/swift_disks.rules.erb
A modules/udev/manifests/init.pp
A modules/udev/manifests/rule.pp
5 files changed, 39 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/42/371642/1

diff --git a/modules/profile/manifests/swift/storage/labs.pp 
b/modules/profile/manifests/swift/storage/labs.pp
index 4fcee4f..27d6cfa 100644
--- a/modules/profile/manifests/swift/storage/labs.pp
+++ b/modules/profile/manifests/swift/storage/labs.pp
@@ -10,18 +10,8 @@
     extents      => '80%FREE',
   }
 
-  file { '/etc/udev/rules.d/90-swift-lvm.rules':
-    ensure  => present,
-    owner   => 'root',
-    group   => 'root',
-    mode    => '0444',
+  udev::rule { 'swift_storage_labs':
     content => 'ENV{DM_LV_NAME}=="lv-a1", ENV{DM_VG_NAME}=="vd", 
SYMLINK+="swift/lv-a1"',
-    notify  => Exec['swift_udev_reload'],
     require => Lvm::Logical_volume['lv-a1'],
-  }
-
-  exec { 'swift_labs_udev_reload':
-    command     => '/sbin/udevadm control --reload && /sbin/udevadm trigger',
-    refreshonly => true,
   }
 }
diff --git a/modules/swift/manifests/storage.pp 
b/modules/swift/manifests/storage.pp
index 042e669..135297e 100644
--- a/modules/swift/manifests/storage.pp
+++ b/modules/swift/manifests/storage.pp
@@ -135,16 +135,7 @@
                     File['/etc/swift/swift-drive-audit.conf']],
     }
 
-    file { '/lib/udev/rules.d/80-swift-disks.rules':
-        owner  => 'root',
-        group  => 'root',
-        mode   => '0444',
-        source => 'puppet:///modules/swift/80-swift-disks.rules',
-        notify => Exec['swift_udev_reload'],
-    }
-
-    exec { 'swift_udev_reload':
-        command     => '/sbin/udevadm control --reload && /sbin/udevadm 
trigger',
-        refreshonly => true,
+    udev::rule{ 'swift_storage':
+        content => template("${module_name}/swift_disks.rules.erb"),
     }
 }
diff --git a/modules/swift/files/80-swift-disks.rules 
b/modules/swift/templates/swift_disks.rules.erb
similarity index 100%
rename from modules/swift/files/80-swift-disks.rules
rename to modules/swift/templates/swift_disks.rules.erb
diff --git a/modules/udev/manifests/init.pp b/modules/udev/manifests/init.pp
new file mode 100644
index 0000000..22e3e8d
--- /dev/null
+++ b/modules/udev/manifests/init.pp
@@ -0,0 +1,6 @@
+class udev {
+    exec { 'udev_reload':
+        command     => '/sbin/udevadm control --reload && /sbin/udevadm 
trigger',
+        refreshonly => true,
+    }
+}
diff --git a/modules/udev/manifests/rule.pp b/modules/udev/manifests/rule.pp
new file mode 100644
index 0000000..093eab7
--- /dev/null
+++ b/modules/udev/manifests/rule.pp
@@ -0,0 +1,30 @@
+# == udev::rule ==
+#
+# Add a custom udev rule and reload udev
+#
+# === Parameters ===
+# [*content*]
+#   The content of the rule. Required.
+# [*ensure*]
+#   The usual meta-parameter, defaults to present. Valid values are
+#   'absent' and 'present'
+# [*priority*]
+#   The rule priority.
+define udev::rule (
+    $content,
+    $ensure = 'present',
+    $priority = 40,
+) {
+    validate_ensure($ensure)
+
+    require ::udev
+
+    file { "/etc/udev/rules.d/${priority}-${title}.rules":
+        ensure  => $ensure,
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        content => $content,
+        notify  => Exec['udev_reload'],
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/371642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I85bbbbdc3b5509eb078be867a1baa2bf54eca830
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Filippo Giunchedi <fgiunch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to