Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Generate unique uuid for platforms #264

Closed
jquick opened this issue Mar 8, 2018 · 0 comments
Closed

RFC: Generate unique uuid for platforms #264

jquick opened this issue Mar 8, 2018 · 0 comments

Comments

@jquick
Copy link
Contributor

jquick commented Mar 8, 2018

Description

Generate a unique identifier for platforms that can be used to see if your hitting the same box over multiple runs. See if we already have a uuid on the box (via chef client or something else) else create one based on the criteria below.

Unix

  • cat /etc/machine-id || /var/lib/dbus/machine-id || /var/db/dbus/machine-id if valid
  • create uuids like:
      hash = Digest::SHA1.new
      hash.update(string)
      ary = hash.digest.unpack("NnnnnN")
      ary[2] = (ary[2] & 0x0FFF) | (5 << 12)
      ary[3] = (ary[3] & 0x3FFF) | 0x8000
      "%08x-%04x-%04x-%04x-%04x%08x" % ary

taken from https://github.com/rails/rails/blob/a9dc45459abcd9437085f4dd0aa3c9d0e64e062f/activesupport/lib/active_support/core_ext/digest/uuid.rb#L16

  • We could write a uuid to the disk if none exist. /etc/machine-uuid or local if that is not possible

OSX

hardware uuid system_profiler SPHardwareDataType | awk '/UUID/ { print $3; }'

Windows

wmic csproduct get UUID
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid in the registry

  • We could write a uuid to the disk if none exist.

AWS API

Use the account_id

Azure

Use subscription_id, fallback to tenant_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant