Created
September 29, 2014 14:33
-
-
Save discreet/691e388e7eeebdb5a47d to your computer and use it in GitHub Desktop.
Spacewalk Registration Key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# facter rhelkey | |
# | |
# This fact will determine which patching group should be applied | |
# to the server when added to satellite so the need to manually | |
# add servers to groups will be eliminated. | |
Facter.add('rhelkey') do | |
setcode do | |
myenv = Facter.value('hostname').scan(/(^\D+\d)/).to_s | |
odd_even = Facter.value('hostname').scan(/^\D+\d\D+(\d+)/).to_s | |
case myenv | |
when /(prd|p\d)/ | |
if odd_even.to_i.odd? | |
"prd-key1" | |
else | |
"prd-key2" | |
end | |
when /(stg|s\d)/ | |
if odd_even.to_i.odd? | |
"stg-key1" | |
else | |
"stg-key2" | |
end | |
when /(dev\d)/ | |
if odd_even.to_i.odd? | |
"dev-key1" | |
else | |
"dev-key2" | |
end | |
when /(tst\d)/ | |
if odd_even.to_i.odd? | |
"tst-key1" | |
else | |
"tst-key2" | |
end | |
when /(trn\d)/ | |
if odd_even.to_i.odd? | |
"trn-key1" | |
else | |
"trn-key2" | |
end | |
when /(tx|va)\d/ | |
if odd_even.to_i.odd? | |
"admin-key1" | |
else | |
"admin-key2" | |
end | |
else | |
"general-key" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment