Filippo Giunchedi has submitted this change and it was merged.
Change subject: hiera_lookup: recognize labs project and site
......................................................................
hiera_lookup: recognize labs project and site
We failed to extract the labs project name which is required by
modules/puppetmaster/files/labs.hiera.yaml . Extract the project from
the FQDN having the form <hostname>.<project>.<site>.wmflabs
While at it extract the proper site, previously hardcoded to 'eqiad'.
We would abort asking for --site only when site is 'wikimedia'. Also
abort when site is 'nil'.
Update usage doc to mention the labs FQDN format.
Add an example usage for a real world labs project:
$ ./hiera_lookup --fqdn=host.tools.eqiad.wmflabs classes
role::aptly::client
Bug: T129092
Change-Id: I69be054f03477d58de367dd259ffeca9a7a41816
---
M utils/hiera_lookup
1 file changed, 19 insertions(+), 3 deletions(-)
Approvals:
Filippo Giunchedi: Looks good to me, approved
Hashar: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/utils/hiera_lookup b/utils/hiera_lookup
index da78435..3a270b4 100755
--- a/utils/hiera_lookup
+++ b/utils/hiera_lookup
@@ -22,9 +22,12 @@
-h, --help Display this help and exit
If SITE is not provided, it will be derived from the FQDN whenever possible.
+For Wmflabs a FQDN should be: <hostname>.<project>.<site>.wmflabs
-Example:
+Examples:
hiera_lookup --fqdn=mw1020.eqiad.wmnet --roles=mediawiki::appserver
admin::groups
+ hiera_lookup --fqdn=host.tools.eqiad.wmflabs classes
+
end
msg << error
@@ -50,9 +53,22 @@
abort(usage "Error: --fqdn=FQDN is required.") unless scope['::fqdn']
scope['::hostname'] = scope['::fqdn'][/^[^.]+/]
scope['::realm'] = scope['::fqdn'].include?('labs') ? 'labs' : 'production'
+
+ # Detect labs project/site
+ if scope['::realm'] == 'labs'
+ bits = scope['::fqdn'].split('.')
+ unless bits.length == 4
+ Kernel.abort('labs FQDN must be <hostname>.<project>.<site>.wmflabs')
+ end
+ scope['::labsproject'] = bits[1]
+ scope['::site'] = bits[2]
+ end
+
# 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'
+ scope['::site'] ||= scope['::fqdn'].split('.')[-2]
+ if scope['::site'] == 'wikimedia' || scope['::site'].nil?
+ abort(usage "\nError: --site=SITE is required if the FQDN doesn't contain
it")
+ end
# Transform roles in the form puppet expects
if scope['::roles']
--
To view, visit https://gerrit.wikimedia.org/r/276346
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I69be054f03477d58de367dd259ffeca9a7a41816
Gerrit-PatchSet: 8
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Hashar <[email protected]>
Gerrit-Reviewer: Alexandros Kosiaris <[email protected]>
Gerrit-Reviewer: Filippo Giunchedi <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits