]> git.openstreetmap.org Git - chef.git/commitdiff
Handle machines with a single interface
authorTom Hughes <tom@compton.nu>
Fri, 12 Nov 2021 19:53:27 +0000 (19:53 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 12 Nov 2021 19:53:27 +0000 (19:53 +0000)
cookbooks/hardware/templates/default/lldp.rb.erb

index 6ccd1cdfa4c73e89bf456e12f7f3e1632b2c702e..fb8d8cf0ff41ef1e57b6bac7574365bcb76095f1 100644 (file)
@@ -8,7 +8,13 @@ Ohai.plugin(:Lldp) do
 
     json = JSON.parse(%x(/usr/sbin/lldpctl -f json))
 
-    json["lldp"]["interface"].each do |interface|
+    interfaces = if json["lldp"]["interface"].is_a?(Array)
+                   json["lldp"]["interface"]
+                 else
+                   [json["lldp"]["interface"]]
+                 end
+
+    interfaces.each do |interface|
       interface.each do |name, details|
         lldp[name] = details
       end