Skip to content

Instantly share code, notes, and snippets.

@kjetilho
Created September 1, 2016 11:48
Show Gist options
  • Save kjetilho/915d4130e91525be3a5642754094b4c2 to your computer and use it in GitHub Desktop.
Save kjetilho/915d4130e91525be3a5642754094b4c2 to your computer and use it in GitHub Desktop.
phys_interfaces fact
# phys_interfaces returns network interfaces associated with a physical device
# as a comma separated list.
#
# Written by kjetil.homme@redpill-linpro.com 2016
# Released into the public domain
require 'facter'
Facter.add("phys_interfaces") do
confine :kernel => :linux
setcode do
Dir.glob('/sys/class/net/*/device').map { |p|
p.split('/')[4]
}.join(',')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment