Alexandros Kosiaris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/167645

Change subject: Introduce rack facts based on LLDP facts
......................................................................

Introduce rack facts based on LLDP facts

By using the LLDP facts and making some assumptions that are constant
throughout our infrastructure we can deduce the rack row a server is in
and its rack

Change-Id: I80bd13ed93366f702e3b8d3c06536c7b877ca6a1
---
A modules/base/lib/facter/rack.rb
1 file changed, 21 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/45/167645/1

diff --git a/modules/base/lib/facter/rack.rb b/modules/base/lib/facter/rack.rb
new file mode 100644
index 0000000..d05d768
--- /dev/null
+++ b/modules/base/lib/facter/rack.rb
@@ -0,0 +1,21 @@
+# These two are based on a heuristic and assumptions and are possible to break
+Facter.add('rackrow') do
+    confine :kernel => %w{Linux FreeBSD OpenBSD}
+    setcode do
+        lldppeers = Facter.value('lldppeers')
+        lldppeers.split(',').gsub('asw-', '')
+    end
+end
+Facter.add('rack') do
+    confine :kernel => %w{Linux FreeBSD OpenBSD}
+    setcode do
+        rackrow = Facter.value('rackrow')
+        lldp_eth0 = Facter.value('lldpswport_eth0')
+        if ( lldp_eth0 =~ /[gx]e-(\d+)\/\d\/\d(\.\d+)/ )
+            rack = $1 + 1 #We don't have 0 based racks
+        else
+            rack = 'Unknown'
+        end
+        "#{rack}-#{rackrow}"
+    end
+end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I80bd13ed93366f702e3b8d3c06536c7b877ca6a1
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to