Created
January 31, 2018 16:19
-
-
Save rmueck/a873e39bb38b4d0cfe8d710df693b908 to your computer and use it in GitHub Desktop.
Custom fact for Puppet to choose right interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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