-
-
Save c33s/dcc0145a261eacabc9f200462c2c5cc6 to your computer and use it in GitHub Desktop.
Puppet: Generate a unique integer id base on the hostname
This file contains hidden or 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
| # | |
| # Generate a unique integer id base on the hostname | |
| # It works by stripping $domain from the $::fqdn, | |
| # removing all characters except alphanumeric and converting to base 10 | |
| # $domain is provided if you have complex domains like *.hosting.example.com | |
| # | |
| class uniqueid ( | |
| $domain = $::domain, | |
| ) { | |
| $node_id = inline_template("<%= '$::fqdn'.gsub('$domain','').gsub(/[^a-z0-9]/i,'').to_i(36) %>") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment