Ask Your Question

Why are interface names cleansed of everything except letters and numbers? Is there a way to get the actual interface name?

asked 2014-10-24 14:18:55 -0500

carpat gravatar image

I'm beginning to use puppet to manage a Windows server, and am trying to update some network settings via netsh. However, the interfaces fact has all of the characters replaced that are not latin letters and digits by Facter::Util::IP.alphafy, so I get Local_Area_Connection instead of Local Area Connection. I assume I should be using something else to get the interface names?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-10-25 22:37:25 -0500

cbarbour gravatar image

Hi Carpat,

I had to solve the same problem in order to build a module that manages DNS resolvers on Windows. Unfortunately, the original interface names are not available to the Puppet DSL. You have two options:

  1. Reconstruct the interface names using regex, by attempting to undo the inteface name normalization.
  2. Write a custom fact that queries WMI and outputs the native interface names.

I went with option number two. Unfortunately, I can't publish the code without approval. I can however advise you that while the network fact is fairly complex, it is entirely possible to design your own network module based upon it.

edit flag offensive delete link more


I ended up going with a custom fact as well - it was actually really easy, the `interfaces` fact is `Facter::Util::IP.get_interfaces.collect { |iface| Facter::Util::IP.alphafy(iface) }.join(",")`, so I just copied that line and removed the `alphafy` call.

carpat gravatar imagecarpat ( 2014-10-27 10:15:57 -0500 )edit

Beautiful. :)

cbarbour gravatar imagecbarbour ( 2014-10-27 12:58:43 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-10-24 14:18:22 -0500

Seen: 49 times

Last updated: Oct 25 '14