Rush has submitted this change and it was merged.

Change subject: hiera_lookup allow debug with '-v'
......................................................................


hiera_lookup allow debug with '-v'

Change-Id: I2c722183a588e5259f66daf2e7c01ec4bfb4c0b5
---
M utils/hiera_lookup
1 file changed, 17 insertions(+), 8 deletions(-)

Approvals:
  Rush: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/utils/hiera_lookup b/utils/hiera_lookup
index 246ba97..1fa0528 100755
--- a/utils/hiera_lookup
+++ b/utils/hiera_lookup
@@ -26,12 +26,6 @@
 rescue LoadError
   abort("Hiera not found - try 'apt-get install ruby-hiera' or 'gem install 
hiera'.")
 end
-abort(usage) if ARGV.include?('-h') || ARGV.include?('--help')
-key = ARGV.pop() || abort(usage "\nError: KEY is required")
-
-$DIR = ENV['PUPPETDIR'] || File.expand_path('../..', __FILE__)
-$LOAD_PATH << File.join($DIR, 'modules/wmflib/lib')
-cfg = File.join($DIR, 'modules/puppetmaster/files/production.hiera.yaml')
 
 # Get the scope from the command line arguments
 def get_scope()
@@ -40,7 +34,6 @@
   abort(usage "Error: --fqdn=FQDN is required.") unless scope['::fqdn']
   scope['::hostname'] = scope['::fqdn'][/^[^.]+/]
   scope['::realm'] = scope['::fqdn'].include?('labs') ? 'labs' : 'production'
-
   # Attempt at determining the site
   scope['::site'] ||= scope['::realm'] == 'labs' ? 'eqiad' : 
scope['::fqdn'].split('.')[-2]
   abort(usage "\nError: --site=SITE is required if the FQDN doesn't contain 
it") if scope['::site'] == 'wikimedia'
@@ -64,8 +57,24 @@
   end
 end
 
+abort(usage) if ARGV.include?('-h') || ARGV.include?('--help') || ARGV.empty?
+if ARGV.include?('-v')
+  verbose = true
+  ARGV.delete('-v')
+else
+  verbose = false
+end
+
+$DIR = ENV['PUPPETDIR'] || File.expand_path('../..', __FILE__)
+$LOAD_PATH << File.join($DIR, 'modules/wmflib/lib')
+cfg = File.join($DIR, 'modules/puppetmaster/files/production.hiera.yaml')
+
+key = ARGV.pop()
+abort(usage "\nError: KEY is required") if key.match('^--')
+
 hiera = Hiera.new(:config => cfg)
-if not get_scope().include?('::debug')
+if not verbose || get_scope().include?('::debug')
     Hiera.logger = "noop"
 end
+
 puts hiera.lookup(key, nil, get_scope(), nil, :priority)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2c722183a588e5259f66daf2e7c01ec4bfb4c0b5
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Rush <r...@wikimedia.org>
Gerrit-Reviewer: Rush <r...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to