Skip to content

Instantly share code, notes, and snippets.

@carroarmato0
Created February 4, 2014 14:27
Show Gist options
  • Save carroarmato0/8804530 to your computer and use it in GitHub Desktop.
Save carroarmato0/8804530 to your computer and use it in GitHub Desktop.
IP regex matching madness Puppet
$parents = $::ipaddress ? {
/^172.16.2.([^1]{1}|[0-9]{2,3})/ => 'some.example.org',
/^172.16.3.([^1]{1}|[0-9]{2,3})/ => 'random.example.org',
/^172.16.4.([^1]{1}|[0-9]{2,3})/ => 'machines.example.org',
/^172.16.5.([^1]{1}|[0-9]{2,3})/ => 'on.example.org',
/^192.168.100/ => 'the.example.org',
/^172\.18\.(?!(1\.2)$)/ => 'network.example.org',
/^10\.0\.(3.([2-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))|((3[3-9]|[4-5][0-9]|6[0-2]).([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5])))|63.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-4])))$/ => 'are.example.org',
/^10\.0\.((64\.([2-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|((6[5-9]|[78][0-9]|9[0-4])\.([1-9][0-9]?|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(95\.([1-9][0-9]?|1[0-9]{2}|2[0-4][0-9]|25[0-4])))$/ => 'partying.example.org',
default => 'hard.example.org',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment