Issue #10278 has been updated by Jan Weiher.
I ran into the same issue: German (and probably other foreign locales) are
breaking facter ifconfig stuff. This patch fixes it for me, but my ruby skills
are rather low so I would appreciate some testing etc.
all the best,
Jan
diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
index b7395e0..f74d859 100644
--- a/lib/facter/util/ip.rb
+++ b/lib/facter/util/ip.rb
@@ -74,7 +74,7 @@ module Facter::Util::IP
def self.get_all_interface_output
case Facter.value(:kernel)
when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD',
'DragonFly'
- output = %x{/sbin/ifconfig -a}
+ output = self.localewrapper("/sbin/ifconfig -a")
when 'SunOS'
output = %x{/usr/sbin/ifconfig -a}
when 'HP-UX'
@@ -90,7 +90,7 @@ module Facter::Util::IP
output = ""
case Facter.value(:kernel)
when 'Linux', 'OpenBSD', 'NetBSD', 'FreeBSD', 'Darwin', 'GNU/kFreeBSD',
'DragonFly'
- output = %x{/sbin/ifconfig #{interface}}
+ output = self.localewrapper("/sbin/ifconfig #{interface}")
when 'SunOS'
output = %x{/usr/sbin/ifconfig #{interface}}
when 'HP-UX'
@@ -199,4 +199,15 @@ module Facter::Util::IP
return $1
end
end
+
+ def self.localewrapper(command)
+ current_lang = ENV['LANG']
+ current_lc_all = ENV['LC_ALL']
+ ENV['LANG'] = 'C'
+ ENV['LC_ALL'] = 'C'
+ output = %x{#{command}}
+ ENV['LANG'] = current_lang
+ ENV['LC_ALL'] = current_lc_all
+ return output
+ end
end
----------------------------------------
Bug #10278: some facts do not work with locales set
https://projects.puppetlabs.com/issues/10278#change-64250
Author: Bernhard Schmidt
Status: Needs More Information
Priority: Normal
Assignee:
Category: interface
Target version:
Keywords: locale
Branch:
Affected Facter version: 1.6.2
facter does not clean locale environment variables prior to executing commands
and sometimes falls over the localized output. I'm not sure whether this is
relevant for facter being executed by puppet, but it makes debugging a lot
harder. For example with the macaddress fact
<pre>
root@mail:~# facter | grep mac
Could not retrieve macaddress: undefined method `split' for nil:NilClass
Could not retrieve macaddress: undefined method `split' for nil:NilClass
root@mail:~# LANG=C LC_ALL=C facter | grep mac
macaddress => 52:54:00:94:f3:1c
macaddress_eth0 => 52:54:00:94:f3:1c
</pre>
The reason is that macaddress.rb is looking for ether or HWaddr
<pre>
setcode do
ether = []
output = Facter::Util::Resolution.exec("/sbin/ifconfig -a")
output.each_line do |s|
ether.push($1) if s =~ /(?:ether|HWaddr)
(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/
end
Facter::Util::Macaddress.standardize(ether[0])
</pre>
which is not contained in the localized output
<pre>
root@mail:~# ifconfig -a
eth0 Link encap:Ethernet Hardware Adresse 52:54:00:94:f3:1c
inet Adresse:80.244.243.68 Bcast:80.244.243.71 Maske:255.255.255.248
inet6-Adresse: 2001:4d88:1005::25:1:2/64 Gültigkeitsbereich:Global
inet6-Adresse: fe80::5054:ff:fe94:f31c/64
Gültigkeitsbereich:Verbindung
UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
RX packets:4018239 errors:0 dropped:0 overruns:0 frame:0
TX packets:790814 errors:0 dropped:0 overruns:0 carrier:0
Kollisionen:0 Sendewarteschlangenlänge:1000
RX bytes:658542927 (628.0 MiB) TX bytes:162143875 (154.6 MiB)
</pre>
The full difference between a LANG=de_DE and LANG=C run on the same machine:
<pre>
--- /tmp/facter.DE 2011-10-25 22:17:13.568013673 +0200
+++ /tmp/facter.C 2011-10-25 22:17:19.504013672 +0200
@@ -8,7 +8,11 @@
hostname => mail
id => root
interfaces => eth0,lo
-ipaddress => 80.244.243.71
+ipaddress => 80.244.243.68
+ipaddress6 => 2001:4d88:1005::25:1:2
+ipaddress6_eth0 => 2001:4d88:1005::25:1:2
+ipaddress_eth0 => 80.244.243.68
+ipaddress_lo => 127.0.0.1
is_virtual => true
kernel => Linux
kernelmajversion => 3.0
@@ -19,9 +23,16 @@
lsbdistid => Debian
lsbdistrelease => testing
lsbmajdistrelease => testing
+macaddress => 52:54:00:94:f3:1c
+macaddress_eth0 => 52:54:00:94:f3:1c
manufacturer => Bochs
-memoryfree => 345.66 MB
+memoryfree => 348.94 MB
memorysize => 749.06 MB
+netmask => 255.255.255.248
+netmask_eth0 => 255.255.255.248
+netmask_lo => 255.0.0.0
+network_eth0 => 80.244.243.64
+network_lo => 127.0.0.0
operatingsystem => Debian
operatingsystemrelease => wheezy/sid
osfamily => Debian
@@ -45,5 +56,5 @@
uptime => 1 day
uptime_days => 1
uptime_hours => 29
-uptime_seconds => 107884
+uptime_seconds => 107890
virtual => kvm
</pre>
uptime_seconds and memory_* has to be ignored here of course.
facter should probably reset LANG/LC* variables or even better use a sane API,
for example /sys/class/net/ethx/address on platforms where it is supported
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-bugs?hl=en.