Skip to content

Instantly share code, notes, and snippets.

@adamcrews
Created April 1, 2014 18:14
Show Gist options
  • Save adamcrews/9919791 to your computer and use it in GitHub Desktop.
Save adamcrews/9919791 to your computer and use it in GitHub Desktop.
zone fact
Facter.add(:my_zone) do
# confine :kernel => :Linux
setcode do
net = Facter.value('ipaddress').split('.').shift(2).join('.')
# scheme is: 10.13x.x.x == west_datacenter and so on
case net
when /^10\.13[0-9]$/
zone = 'west_datacenter'
when /^10\.14[0-9]$/
zone = 'euro_datacenter'
when /^10\.15[0-9]$/
zone = 'east_datacenter'
else
zone = 'unknown'
end
zone
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment