Andrew Bogott has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/368606 )
Change subject: get $::labsproject from the certname
......................................................................
get $::labsproject from the certname
If we enforce <host>.<project>.<site>.wmflabs
certnames then we can rely on the project being
in the certname so there's no need to call out
to the metadata service.
This should be faster and also avoids trusting
the instance to report its project.
Bug: T171289
Change-Id: Ie23f221e9a2c7906820c37dcfbddd121c1212eba
---
M manifests/realm.pp
D modules/base/lib/facter/labsprojectfrommetadata.rb
2 files changed, 4 insertions(+), 25 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/06/368606/1
diff --git a/manifests/realm.pp b/manifests/realm.pp
index 900ca27..931b8eb 100644
--- a/manifests/realm.pp
+++ b/manifests/realm.pp
@@ -21,13 +21,10 @@
}
if $realm == 'labs' {
-
- $labs_metal = hiera('labs_metal', {})
- if has_key($labs_metal, $::hostname) {
- $labsproject = $labs_metal[$::hostname]['project']
- } else {
- $labsproject = $::labsprojectfrommetadata
- }
+ # Pull the project name from the certname.
+ # Labs certs are <hostname>.<projname>.<site>.wmflabs
+ $pieces = split($trusted['certname'], '[.]')
+ $labsproject = $pieces[1]
if $::labsproject == undef {
fail('Failed to determine $::labsproject')
diff --git a/modules/base/lib/facter/labsprojectfrommetadata.rb
b/modules/base/lib/facter/labsprojectfrommetadata.rb
deleted file mode 100644
index 8d738d3..0000000
--- a/modules/base/lib/facter/labsprojectfrommetadata.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# labsprojectfrommetadata.rb
-#
-# This fact pulls the labs project out of instance metadata
-
-require 'facter'
-
-Facter.add(:labsprojectfrommetadata) do
- setcode do
- domain = Facter::Util::Resolution.exec("hostname -d").chomp
- if (domain.end_with? ".wmflabs") || (domain.end_with? ".labtest")
- # query the nova metadata service at 169.254.169.254
- metadata = Facter::Util::Resolution.exec("curl -f
http://169.254.169.254/openstack/2015-10-15/meta_data.json/ 2> /dev/null | jq
'.project_id'").chomp
- metadata.slice(1, metadata.length - 2) # strip quotes
- else
- nil
- end
- end
-end
--
To view, visit https://gerrit.wikimedia.org/r/368606
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie23f221e9a2c7906820c37dcfbddd121c1212eba
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Andrew Bogott <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits