Skip to content

Instantly share code, notes, and snippets.

@tas50
Created August 31, 2016 17:58
Show Gist options
  • Select an option

  • Save tas50/afc85f1988c5723b3af9c9e74f117084 to your computer and use it in GitHub Desktop.

Select an option

Save tas50/afc85f1988c5723b3af9c9e74f117084 to your computer and use it in GitHub Desktop.
Ohai.plugin(:Acme) do
provides 'acme'
depends 'hostname'
collect_data(:linux, :darwin, :freebsd) do
acme Mash.new
if fqdn.to_s.downcase.include?('acme.net')
# extract just the datacenter portion using our standard linux naming schema of vps-123.POP.acme.net. Handle PHX2 -> PHX also
acme[:pop] = fqdn.split('.')[-3].gsub(/[0-9]/, '').upcase
end
end
collect_data(:windows) do
acme Mash.new
# extract just the datacenter portion using our standard windows naming schema of vps-123-POP.acme.net. Handle PHX2 -> PHX also
acme[:pop] = fqdn.split('.')[-3].split('-')[-1].gsub(/[0-9]/, '').upcase
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment