puppetlabs/facter — pull request #476 by cdemonchy (2013-07-11 18:27:39+00:00)
Title: ip address fact return full ifconfig output on some systems

Hi,

In the version 1.7.2 of facter, the fact ip address returns the full ifconfig output on some systems.

The function ipaddres for linux (ipaddress.rb:27) returns the variable ouptput when it does not find any ip rather than nil. And facter stops the processing instead of using ohter functions.

I've the case on linux system with a french locale.

```
% LC_ALL=fr_FR.UTF-8 ruby -I lib bin/facter ipaddress
lo Link encap:Boucle locale
inet adr:127.0.0.1 Masque:255.0.0.0
adr inet6: ::1/128 Scope:Hôte
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:0
RX bytes:260 (260.0 B) TX bytes:260 (260.0 B)

wlan0 Link encap:Ethernet HWaddr ac:81:12:2d:86:25
inet adr:192.168.1.83 Bcast:192.168.1.255 Masque:255.255.255.0
adr inet6: fe80::ae81:12ff:fe2d:8625/64 Scope:Lien
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:31416 errors:0 dropped:0 overruns:0 frame:0
TX packets:22385 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 lg file transmission:1000
RX bytes:39065815 (37.2 MiB) TX bytes:3580072 (3.4 MiB)

% LC_ALL=C ruby -I lib bin/facter ipaddress
192.168.1.83
```

As the regex don't match, the function return the variable `output`.

I've attached a fix for this issue.

With the new code, the functions ipaddress for linux and *BSD are almost identical. The regex has an optionnal field addr in supplement. I think the two functions can be merged, i don't try as i don't have a bsd to test.

Thanks to @nekolover for his help.

Regards