Skip to content

Instantly share code, notes, and snippets.

@rmueck
Created January 31, 2018 16:19
Show Gist options
  • Save rmueck/a873e39bb38b4d0cfe8d710df693b908 to your computer and use it in GitHub Desktop.
Save rmueck/a873e39bb38b4d0cfe8d710df693b908 to your computer and use it in GitHub Desktop.
Custom fact for Puppet to choose right interface
Facter.add("default_if") do
confine :kernel => :linux
setcode do
return nil unless FileTest.exists?("/sbin/ip")
output = %x{/sbin/ip route list match 0.0.0.0}.split("\n")[0]
output.sub(/.*\s*dev\s+([^\s]+)\s*.*/, '\1')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment