facter

132 views
Skip to first unread message

Adam Ryczkowski

unread,
Nov 20, 2009, 4:20:19 PM11/20/09
to Puppet Users
After a fresh install from source, facter displays suspected messages
(errors? warnings?):

# facter
Could not retrieve lsbdistcodename: can't convert Array into String
Could not retrieve lsbdistcodename: can't convert Array into String
Could not retrieve lsbdistid: can't convert Array into String
Could not retrieve lsbdistid: can't convert Array into String
Could not retrieve lsbrelease: can't convert Array into String
Could not retrieve lsbrelease: can't convert Array into String
Could not retrieve lsbdistdescription: can't convert Array into String
Could not retrieve lsbdistdescription: can't convert Array into String
Could not retrieve virtual: undefined method `each_line' for #<Array:
0xb79c9250>
Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistid: can't convert Array into String
Could not retrieve lsbdistid: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve virtual: undefined method `each_line' for #<Array:
0xb7b5b910>
/usr/local/lib/site_ruby/1.8/puppet/external/dot.rb:57: warning:
already initialized constant NODE_OPTS
/usr/local/lib/site_ruby/1.8/puppet/external/dot.rb:97: warning:
already initialized constant EDGE_OPTS
/usr/local/lib/site_ruby/1.8/puppet/external/dot.rb:112: warning:
already initialized constant GRAPH_OPTS

I have followed these minimalistic steps to recreate a problem on
Ubuntu Jaunty 9.04:

1. apt-get install git-core ruby libmocha-ruby librspec-ruby rubygems
2. gem install ZenTest
3. git clone git://github.com/reductivelabs/facter
4. cd facter
5. ./install.rb

Should I ignore these messages?

James Turnbull

unread,
Nov 20, 2009, 6:03:41 PM11/20/09
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Why are you installing from source instead of using a package? You
are also installing Facter HEAD above - which is not a stable
release - and may in fact on occasion (rarely) be even broken.

I recommend using a supported, stable release.

Barring that please run:

# facter --debug

And provide the results please.

Regards

James Turnbull

- --
Author of:
* Pro Linux System Administration (http://tinyurl.com/linuxadmin)
* Pulling Strings with Puppet (http://tinyurl.com/pupbook)
* Pro Nagios 2.0 (http://tinyurl.com/pronagios)
* Hardening Linux (http://tinyurl.com/hardeninglinux)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEVAwUBSwcgTSFa/lDkFHAyAQIuowf8CUqgoBdsqky6F3M6H5oOD1p//47B/w7K
+E+H2cmQ8eBoPt7+ArE1UYXC0Mb4jGopouRW5RqJp/ZRSZNvG/lPr/EmbmHO0C6j
4KE/Vle4sOMM/6uFpm/LFwzEm3hRGAgE0XbRLJJOfAy+Zlh9XyVl0qd7xW9vxMRK
aAr/+NTqNzUPyzYd5FBvTnBsyEcfUtQxTFwNY2j2DCMssu9L2WyD9nva08Ez9UPe
HINLjsOi2lRwnvxdSlNzsdLH6GlwNkUO7xvf7Qp1CtB/PW8oOZgsbDIXxlawAR9u
LG5iWXFBspXp3mL+WE5ybDyO7VQTFTHx1lhnNruezA8zEwe0GsY5eQ==
=69r8
-----END PGP SIGNATURE-----

Michael DeHaan

unread,
Dec 31, 2009, 9:42:05 AM12/31/09
to Puppet Users
I found this post from Nov 20 regarding a bug in facter. James
Turnbull was asking then for debug output, which I've provided a bit
later.

The real trick though is this:

[mdehaan@eng-dhcp-105 facter]$ ack lsbdistid *
lib/facter/operatingsystem.rb
11: if Facter.value(:lsbdistid) == "Ubuntu"


There's nothing that sets this value anywhere in facter.

"operatingsystem" seems to be a close candidate.

A similar problem occurs with :lsbdistrelease, which is also never
set.

[mdehaan@eng-dhcp-105 facter]$ sudo facter --debug


Could not retrieve lsbdistid: can't convert Array into String
Could not retrieve lsbdistid: can't convert Array into String

value for lsbdistid is still nil
value for netmask_wmaster0 is still nil


Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String

value for lsbdistrelease is still nil


Could not retrieve virtual: undefined method `each_line' for #<Array:

0xb6c694fc>
value for virtual is still nil
value for macaddress_wmaster0 is still nil
value for netmask_pan0 is still nil


Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String

value for lsbdistrelease is still nil


Could not retrieve lsbdistrelease: can't convert Array into String
Could not retrieve lsbdistrelease: can't convert Array into String

value for lsbdistrelease is still nil
value for lsbmajdistrelease is still nil


Could not retrieve lsbrelease: can't convert Array into String
Could not retrieve lsbrelease: can't convert Array into String

value for lsbrelease is still nil
value for ipaddress_wmaster0 is still nil
value for cfkey is still nil
value for network_wmaster0 is still nil
Found no suitable resolves of 2 for iphostnumber
value for iphostnumber is still nil


Could not retrieve lsbdistdescription: can't convert Array into String
Could not retrieve lsbdistdescription: can't convert Array into String

value for lsbdistdescription is still nil
value for ipaddress_pan0 is still nil


Could not retrieve lsbdistcodename: can't convert Array into String
Could not retrieve lsbdistcodename: can't convert Array into String

value for lsbdistcodename is still nil


Could not retrieve virtual: undefined method `each_line' for #<Array:

0xb6a6b984>
value for virtual is still nil
value for network_pan0 is still nil


Could not retrieve lsbdistid: can't convert Array into String
Could not retrieve lsbdistid: can't convert Array into String

value for lsbdistid is still nil
architecture => i386
domain => rdu.lulu.com
facterversion => 1.5.7
fqdn => eng-dhcp-105.rdu.lulu.com
hardwareisa => i686
hardwaremodel => i686
hostname => eng-dhcp-105
id => root
interfaces => eth0,pan0,wlan0,wmaster0
ipaddress => 10.4.7.105
ipaddress_eth0 => 10.4.7.105
ipaddress_wlan0 => 10.4.7.107
is_virtual => false
kernel => Linux
kernelmajversion => 2.6
kernelrelease => 2.6.30.9-96.fc11.i686.PAE
kernelversion => 2.6.30.9
macaddress => 00:1C:25:78:ED:6C
macaddress_eth0 => 00:1C:25:78:ED:6C
macaddress_pan0 => 26:83:68:F8:A6:AC
macaddress_wlan0 => 00:1F:3B:16:12:89
manufacturer => LENOVO
memoryfree => 1.56 GB
memorysize => 1.94 GB
netmask => 255.255.255.0
netmask_eth0 => 255.255.255.0
netmask_wlan0 => 255.255.255.0
network_eth0 => 10.4.7.0
network_wlan0 => 10.4.7.0
operatingsystem => Fedora
operatingsystemrelease => 11
path => /sbin:/bin:/usr/sbin:/usr/bin
physicalprocessorcount => 1
processor0 => Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz
processor1 => Intel(R) Core(TM)2 Duo CPU T8100 @ 2.10GHz
processorcount => 2
productname => 6460DWU
ps => ps -ef
puppetversion => 0.24.8
rubysitedir => /usr/lib/ruby/site_ruby/1.8
rubyversion => 1.8.6
selinux => true
selinux_enforced => true
selinux_mode => targeted
selinux_policyversion => 24
serialnumber => L3K4789
sshdsakey => (snip)
sshrsakey => (snip)
swapfree => 3.91 GB
swapsize => 3.91 GB
timezone => EST
type => Notebook
uniqueid => 007f0100
uptime => 2 days
uptime_days => 2
uptime_hours => 48
uptime_seconds => 172900

This leads to extra output from puppetca each time it is run:

[mdehaan@eng-dhcp-105 facter]$ sudo puppetca --list


Could not retrieve lsbdistid: can't convert Array into String

No certificates to sign

I'd provide a patch though I'm not sure what the intent is here.

--Michael

On Nov 20, 6:03 pm, James Turnbull <ja...@lovedthanlost.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Adam Ryczkowski wrote:
> > After a fresh install from source, facter displays suspected messages
> > (errors? warnings?):
>
> > # facter

> >Couldnotretrievelsbdistcodename: can't convert Array into String
> >Couldnotretrievelsbdistcodename: can't convert Array into String
> >Couldnotretrievelsbdistid: can't convert Array into String
> >Couldnotretrievelsbdistid: can't convert Array into String
> >Couldnotretrievelsbrelease: can't convert Array into String
> >Couldnotretrievelsbrelease: can't convert Array into String
> >Couldnotretrievelsbdistdescription: can't convert Array into String
> >Couldnotretrievelsbdistdescription: can't convert Array into String
> >Couldnotretrievevirtual: undefined method `each_line' for #<Array:
> > 0xb79c9250>
> >Couldnotretrievelsbdistrelease: can't convert Array into String
> >Couldnotretrievelsbdistrelease: can't convert Array into String
> >Couldnotretrievelsbdistrelease: can't convert Array into String
> >Couldnotretrievelsbdistrelease: can't convert Array into String
> >Couldnotretrievelsbdistid: can't convert Array into String
> >Couldnotretrievelsbdistid: can't convert Array into String
> >Couldnotretrievelsbdistrelease: can't convert Array into String
> >Couldnotretrievelsbdistrelease: can't convert Array into String
> >Couldnotretrievevirtual: undefined method `each_line' for #<Array:


> > 0xb7b5b910>
> > /usr/local/lib/site_ruby/1.8/puppet/external/dot.rb:57: warning:
> > already initialized constant NODE_OPTS
> > /usr/local/lib/site_ruby/1.8/puppet/external/dot.rb:97: warning:
> > already initialized constant EDGE_OPTS
> > /usr/local/lib/site_ruby/1.8/puppet/external/dot.rb:112: warning:
> > already initialized constant GRAPH_OPTS
>
> > I have followed these minimalistic steps to recreate a problem on
> > Ubuntu Jaunty 9.04:
>
> > 1. apt-get install git-core ruby libmocha-ruby librspec-ruby rubygems
> > 2. gem install ZenTest
> > 3. git clone git://github.com/reductivelabs/facter
> > 4. cd facter
> > 5. ./install.rb
>
> Why are you installing from source instead of using a package?  You

> are also installing Facter HEAD above - which isnota stable

James Turnbull

unread,
Dec 31, 2009, 10:25:29 AM12/31/09
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael DeHaan wrote:
> I found this post from Nov 20 regarding a bug in facter. James
> Turnbull was asking then for debug output, which I've provided a bit
> later.
>
> The real trick though is this:
>
> [mdehaan@eng-dhcp-105 facter]$ ack lsbdistid *
> lib/facter/operatingsystem.rb
> 11: if Facter.value(:lsbdistid) == "Ubuntu"
>
>
> There's nothing that sets this value anywhere in facter.
>
> "operatingsystem" seems to be a close candidate.

It's set in lsb.rb.

>
> A similar problem occurs with :lsbdistrelease, which is also never
> set.

Ditto.

Though something is perhaps not kosher with it and lsb_release
although it works fine for me:

lsbdistcodename => Cambridge
lsbdistdescription => Fedora release 10 (Cambridge)
lsbdistid => Fedora
lsbdistrelease => 10
lsbmajdistrelease => 10

Regards

James Turnbull

- --
Author of:
* Pro Linux System Administration (http://tinyurl.com/linuxadmin)
* Pulling Strings with Puppet (http://tinyurl.com/pupbook)
* Pro Nagios 2.0 (http://tinyurl.com/pronagios)
* Hardening Linux (http://tinyurl.com/hardeninglinux)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEVAwUBSzzCaSFa/lDkFHAyAQKs8Qf8Dvu7HmsHO0llhi/rkWxCP5lY6nShu7ZJ
pqFjhMkb3OgzW06DX1KyRetvwyoF5uP77+92nS+P1NOXlzYYaJ+E0ysCYSDZ7z8v
iuiN+tBLsW9sE+yi0T2xGH9yEbcMfSmu7za7II5aEqxvEg0PF4f+xWdMucMf6mpH
Mk8nULcAfAnGt2EdBW369y5sRaD6oDBdSYfjB3ldjmKF3JfVdnObpvj3bSqi4+pz
++aDQRyFN31/M7nGlbXYGfc4Yw7VOC4Vqe70VosikOgRU87zoiV2UCO24j6TGUqt
w+4ymBqgPP6X8YThgrj1qTyfHMorJx3i1S3BRU8ID3SHNAfkPhkZqw==
=gGVj
-----END PGP SIGNATURE-----

Michael DeHaan

unread,
Dec 31, 2009, 11:15:37 AM12/31/09
to puppet...@googlegroups.com
> It's set in lsb.rb.

Thanks.

>
> Though something is perhaps not kosher with it and lsb_release

> although it works fine for me...
>

The issue seems to be that Facter::Util::Resolution::exec is returning
an array, not a string.
My version of Ruby doesn't seem to want to do pattern matches against
arrays, it seems, though that might have been legal on older Ruby
versions?

diff --git a/lib/facter/lsb.rb b/lib/facter/lsb.rb
index f54d75f..2df715f 100644
--- a/lib/facter/lsb.rb
+++ b/lib/facter/lsb.rb
@@ -25,7 +25,7 @@
unless defined?(@@lsbdata) and defined?(@@lsbtime) and
(Time.now.to_i - @@lsbtime.to_i < 5)
type = nil
@@lsbtime = Time.now
- @@lsbdata =
Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null')
+ @@lsbdata =
Facter::Util::Resolution.exec('lsb_release -a 2>/dev/null').join("\n")
end

if pattern.match(@@lsbdata)

>
> Regards
>
> James Turnbull
>
> - --
> Author of:
> * Pro Linux System Administration (http://tinyurl.com/linuxadmin)
> * Pulling Strings with Puppet (http://tinyurl.com/pupbook)
> * Pro Nagios 2.0 (http://tinyurl.com/pronagios)
> * Hardening Linux (http://tinyurl.com/hardeninglinux)
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (Darwin)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEVAwUBSzzCaSFa/lDkFHAyAQKs8Qf8Dvu7HmsHO0llhi/rkWxCP5lY6nShu7ZJ
> pqFjhMkb3OgzW06DX1KyRetvwyoF5uP77+92nS+P1NOXlzYYaJ+E0ysCYSDZ7z8v
> iuiN+tBLsW9sE+yi0T2xGH9yEbcMfSmu7za7II5aEqxvEg0PF4f+xWdMucMf6mpH
> Mk8nULcAfAnGt2EdBW369y5sRaD6oDBdSYfjB3ldjmKF3JfVdnObpvj3bSqi4+pz
> ++aDQRyFN31/M7nGlbXYGfc4Yw7VOC4Vqe70VosikOgRU87zoiV2UCO24j6TGUqt
> w+4ymBqgPP6X8YThgrj1qTyfHMorJx3i1S3BRU8ID3SHNAfkPhkZqw==
> =gGVj
> -----END PGP SIGNATURE-----
>

> --
>
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>
>
>

Michael DeHaan

unread,
Dec 31, 2009, 11:32:23 AM12/31/09
to Puppet Users

> > Though something is perhaps not kosher with it and lsb_release
> > although it works fine for me...
>
> The issue seems to be that Facter::Util::Resolution::exec is returning
> an array, not a string.
> My version of Ruby doesn't seem to want to do pattern matches against
> arrays, it seems, though that might have been legal on older Ruby
> versions?
>

In the course of trying to eliminate some other warnings, I am finding
this is not the correct fix. Please ignore my patch.

The code is also trying to call String methods such as each_line on
the results of Facter::Util::Resolution::exec for lspci in other
places. It seems in most places we want a newline joined string.
Any reason to not change it to make it do this?

There's probably some Ruby version change subtlety at work here seeing
things work without warnings for James on F10.

--Michael

Michael DeHaan

unread,
Dec 31, 2009, 11:44:05 AM12/31/09
to Puppet Users

Ok, some more data from git history:
http://github.com/reductivelabs/facter/commit/33fb7709404e706801683e6c47ab7a0a5a1884b1

It looks like "return an array" is new behavior for exec, and maybe it
wasn't backported/tested for all of the old facts. Thoughts?

In this case the best way to go is probably a "return type" parameter
that defaults to strings, and things that want arrays can ask for
them.

--Michael

James Turnbull

unread,
Dec 31, 2009, 7:13:38 PM12/31/09
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael DeHaan wrote:
> Ok, some more data from git history:
> http://github.com/reductivelabs/facter/commit/33fb7709404e706801683e6c47ab7a0a5a1884b1
>
> It looks like "return an array" is new behavior for exec, and maybe it
> wasn't backported/tested for all of the old facts. Thoughts?

Yeah - this is the issue. It's in HEAD so it's not committed to a
release - we can easily fix the facts or adjust or even revert the
commit.

> In this case the best way to go is probably a "return type" parameter
> that defaults to strings, and things that want arrays can ask for
> them.

Yeah - this is in line with where we're going with Facter anyway.

I've re-opened http://projects.reductivelabs.com/issues/2766 with
your investigations.

Thanks for the hard yards poking around at it.

Regards

James Turnbull

- --
Author of:
* Pro Linux System Administration (http://tinyurl.com/linuxadmin)
* Pulling Strings with Puppet (http://tinyurl.com/pupbook)
* Pro Nagios 2.0 (http://tinyurl.com/pronagios)
* Hardening Linux (http://tinyurl.com/hardeninglinux)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEVAwUBSz0+MiFa/lDkFHAyAQJGHwf+PMsma7mu14kmaY1pk3iTz+Wn1O1AZERE
GMQphXaHahfDlZiShy0B2yC1Y+8ZQxMyOfj66E+TGwnveeGBGe7fW9+Q1aGww9D5
1OFdqz7BmN+KxU4JwHkOk6aDEV4TD3R22/71WpUgUcpT51lEDUYbT9w20IZUxgIc
7iz6msAUQX/kq78Y5RPGjqpvm9Mh2YX2TjBfJ7ArFqAVg+lEV9+pec34av1R1IvR
4fSc76hvHcOHroDXtW/Zx/lL0flCXnKKlfiOVJ2/pxqAyrshu6G+aoa3/UNYJTJj
TP4KQ/Ce2O2Flk9/Ewp9Mt6AcJfkY2yHqkhE1OfhVsD/shTE+CH8QA==
=wb+w
-----END PGP SIGNATURE-----

Peter Meier

unread,
Jan 8, 2010, 5:26:55 AM1/8/10
to puppet...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>> Ok, some more data from git history:


>> http://github.com/reductivelabs/facter/commit/33fb7709404e706801683e6c47ab7a0a5a1884b1
>
>> It looks like "return an array" is new behavior for exec, and maybe it
>> wasn't backported/tested for all of the old facts. Thoughts?
>
> Yeah - this is the issue. It's in HEAD so it's not committed to a
> release - we can easily fix the facts or adjust or even revert the
> commit.

Right, my fault. I thought that it would introduce a nice new behavior
and didn't think of the old behavior, as well it looks like the old
behavior wasn't tested enough.

I would propose to just adjust that the exec still returns a string, as
it have done before.

>> In this case the best way to go is probably a "return type" parameter
>> that defaults to strings, and things that want arrays can ask for
>> them.
>
> Yeah - this is in line with where we're going with Facter anyway.

Hmm, I'm not really a fan of such a return type thing. My proposal would
be to have the old behavior (return a string) and then if somebody
really rather likes an array in different places, they could write a
wrapper method which would split the string for them.

> I've re-opened http://projects.reductivelabs.com/issues/2766 with
> your investigations.

If we can agree on a solution, I'll write a patch.

> Thanks for the hard yards poking around at it.

yep, thanks!

cheers pete
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)


Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktHCG4ACgkQbwltcAfKi38ltQCePDX+3Rq1fzHZ8VK5WztgqlV9
ezoAn3yYQJshU74kIrGeh5d8A2oVcCHc
=vdNF
-----END PGP SIGNATURE-----

Paul Nasrat

unread,
Jan 8, 2010, 6:05:22 AM1/8/10
to puppet...@googlegroups.com
> Hmm, I'm not really a fan of such a return type thing. My proposal would
> be to have the old behavior (return a string) and then if somebody
> really rather likes an array in different places, they could write a
> wrapper method which would split the string for them.

+1

Well I think eventually we'll move to a better internal model
supporting data types, for now sticking with key value and letting the
data munging be handled further up the stack for lists is probably
least disruptive for existing facter consumers.

Paul

Reply all
Reply to author
Forward
0 new messages