Skip to content

Instantly share code, notes, and snippets.

@nogweii
Created October 15, 2013 08:58
Show Gist options
  • Save nogweii/6988737 to your computer and use it in GitHub Desktop.
Save nogweii/6988737 to your computer and use it in GitHub Desktop.
Use Frosty Meadow to generate a 'random' name for the server, but first seed Ruby's random with the contents of machine-id. Assumes that /etc/machine-id is valid and exists, and that it contains only hexadecimal numbers. Modify the source to any other source of predictable, guessable machine information. Like the MAC address or similar.
require 'frosty_meadow'
# Use [Frosty Meadow](https://github.com/andyhmltn/frosty-meadow) to generate a
# 'random' name for the server, but first seed Ruby's random with the contents
# of machine-id.
#
# Assumes that /etc/machine-id is valid and exists, and that it contains only
# hexadecimal numbers. Modify the source to any other source of predictable,
# guessable machine information. Like the MAC address or similar.
machine_id_seed = open("/etc/machine-id").read.to_i(16)
old_seed = srand(machine_id_seed)
puts FrostyMeadow.generate
srand(old_seed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment