Skip to content

Instantly share code, notes, and snippets.

@jrottenberg
Created June 26, 2013 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jrottenberg/5872127 to your computer and use it in GitHub Desktop.
Save jrottenberg/5872127 to your computer and use it in GitHub Desktop.
Parse fqdn to generate facts
# ([a-z]{3})-([a-z]*)([0-9]{3}|vip)\.acme\.([a-z]{3})
if Facter.value(:fqdn) =~ /^([a-z]{3})-([a-z]*)([0-9]{3}|vip)\.acme\.([a-z]{3})$/
Facter.add('acme_env') do
setcode {$1}
end
Facter.add('acme_type') do
setcode {$2}
end
Facter.add('acme_instance') do
setcode {$3}
end
Facter.add('acme_location') do
setcode {$4}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment