Andrew Bogott has uploaded a new change for review.

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

Change subject: Fix the projectgid fact.
......................................................................

Fix the projectgid fact.

This was weirdly circular before, where a ganglia manifest
created gmond.conf and then this fact (later) read that conf,
which was used in turn by ganglia.

Mostly moot now wince we aren't using ganglia in labs, but
this fact was still throwing warnings here and there.

Change-Id: I4e942515612b8da477b8782d9d7fc3c00c4bc304
---
M modules/base/lib/facter/projectgid.rb
1 file changed, 14 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/87/181387/1

diff --git a/modules/base/lib/facter/projectgid.rb 
b/modules/base/lib/facter/projectgid.rb
index b76d06c..dcc091c 100644
--- a/modules/base/lib/facter/projectgid.rb
+++ b/modules/base/lib/facter/projectgid.rb
@@ -1,21 +1,30 @@
 # projectgid.rb
 # 
 # This fact provides project_gid (gidNumber) for projects in labs.
-# This is used to set the udp_send_channel port in ganglia's gmond.conf.
 
 require 'facter'
 
 Facter.add(:project_gid) do
   setcode do
-    if not File.exist? '/etc/ganglia/gmond.conf'
+    # Dig deep in ldap for the project name.  This code echoes that in the labs
+    #  firstboot.sh
+    binddn=Facter::Util::Resolution.exec("grep 'binddn' /etc/ldap.conf | sed 
's/.* //'")
+    bindpw=Facter::Util::Resolution.exec("grep 'bindpw' /etc/ldap.conf | sed 
's/.* //'")
+    hostsou=Facter::Util::Resolution.exec("grep 'nss_base_hosts' 
/etc/ldap.conf | sed 's/.* //'")
+
+    id=Facter::Util::Resolution.exec("curl 
http://169.254.169.254/1.0/meta-data/instance-id 2> /dev/null")
+    domain=Facter::Util::Resolution.exec("hostname -d")
+    idfqdn="#{id}.#{domain}"
+    project=Facter::Util::Resolution.exec("ldapsearch -x -D #{binddn} -w 
#{bindpw} -b #{hostsou} \"dc=#{idfqdn}\" puppetvar | grep 'instanceproject' | 
sed 's/.*=//'")
+    if not project
       return "none"
     end
-    project_name = Facter::Util::Resolution.exec("egrep -A1 '^cluster {' 
/etc/ganglia/gmond.conf | awk -F '\"' '/name =/ {print $2}'").chomp
-    gid = Facter::Util::Resolution.exec("getent group project-#{project_name} 
| cut -d : -f 3")
+
+    gid = Facter::Util::Resolution.exec("getent group project-#{project} | cut 
-d : -f 3")
     if gid
       gid.chomp
     else
-      "none"
+      "none\n"
     end
   end
 end

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e942515612b8da477b8782d9d7fc3c00c4bc304
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <abog...@wikimedia.org>

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

Reply via email to