Bug #1918
facter --puppet doesn't work when puppet's vardir or libdir are modified
| Status: | Closed | Start: | 01/29/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | binary | |||
| Target version: | 1.5.5 | |||
| Keywords: | Branch: | |||
| Votes: | 0 |
Description
My facter doesn’t seem to do the right thing with the —puppet option. It doesn’t seem to output my custom rules.
The values are picked up by puppet when used, but not by facter on the command line.
Details:
Files:
/etc/puppet/puppet.conf: [main] logdir = /var/log/puppet vardir = /var/lib/puppet ssldir = /var/lib/puppet/ssl rundir = /var/run/puppet pluginsync = true factpath = /var/lib/puppet/lib/facter
[root@foo-vm:~]# facter —puppet architecture => amd64 domain => dc1.whee.com facterversion => 1.5.1 fqdn => foo-vm.dc1.whee.com hardwareisa => unknown hardwaremodel => x86_64 hostname => foo-vm id => root interfaces => eth0,sit0 ipaddress => 192.168.1.162 ipaddress_eth0 => 192.168.1.162 kernel => Linux kernelrelease => 2.6.18-6-xen-amd64 kernelversion => 2.6.18 lsbdistcodename => etch lsbdistdescription => Debian GNU/Linux 4.0 (etch) lsbdistid => Debian lsbdistrelease => 4.0 lsbmajdistrelease => 4 macaddress => 00:16:3E:26:C9:DC macaddress_eth0 => 00:16:3E:26:C9:DC memoryfree => 612.24 MB memorysize => 2.00 GB netmask => 255.255.255.0 netmask_eth0 => 255.255.255.0 operatingsystem => Debian operatingsystemrelease => 4.0 processor0 => Intel® Xeon® CPU 5150 @ 2.66GHz processor1 => Intel® Xeon® CPU 5150 @ 2.66GHz processorcount => 2 ps => ps -ef puppetversion => 0.24.7 rubysitedir => /usr/local/lib/site_ruby/1.8 rubyversion => 1.8.7 sshdsakey => blahblahblah sshrsakey => blahblahblah swapfree => 1023.97 MB swapsize => 1023.99 MB uniqueid => a8c0a25b virtual => xenu
[root@foo-vm:~]# FACTERLIB=/var/lib/puppet/lib/facter/ facter
acpi_available => absent
architecture => amd64
definterface => eth0
domain => dc1.whee.com
facterversion => 1.5.1
fqdn => foo-vm.dc1.whee.com
hardwareisa => unknown
hardwaremodel => x86_64
hostname => foo-vm
id => root
interfaces => eth0,sit0
interfacez => eth0
ipaddress => 192.168.1.162
ipaddress_eth0 => 192.168.1.162
kernel => Linux
kernelrelease => 2.6.18-6-xen-amd64
kernelversion => 2.6.18
lib => /var/lib/puppet/lib/facter/
lsbdistcodename => etch
lsbdistdescription => Debian GNU/Linux 4.0 (etch)
lsbdistid => Debian
lsbdistrelease => 4.0
lsbmajdistrelease => 4
macaddress => 00:16:3E:26:C9:DC
macaddress_eth0 => 00:16:3E:26:C9:DC
memoryfree => 633.28 MB
memorysize => 2.00 GB
netmask => 255.255.255.0
netmask_eth0 => 255.255.255.0
operatingsystem => Debian
operatingsystemrelease => 4.0
processor0 => Intel® Xeon® CPU 5150 @ 2.66GHz
processor1 => Intel® Xeon® CPU 5150 @ 2.66GHz
processorcount => 2
ps => ps -ef
puppetversion => 0.24.7
rubysitedir => /usr/local/lib/site_ruby/1.8
rubyversion => 1.8.7
sshdsakey => wheewheewhee
sshrsakey => foofoofoofoo
swapfree => 1023.97 MB
swapsize => 1023.99 MB
uniqueid => a8c0a25b
virtual => xenu
whatraid => unknown
[root@foo-vm:~]# ls -l /var/lib/puppet/lib/facter/
total 20
-rw-r—r— 1 root root 234 2009-01-29 11:26 acpi_available.rb
-rw-r—r— 1 root root 619 2009-01-29 12:55 definterface.rb
-rw-r—r— 1 root root 427 2009-01-29 12:33 interfaces.rb
-rw-r—r— 1 root root 1441 2009-01-29 11:26 isvm.rb
-rw-r—r— 1 root root 877 2009-01-29 11:26 whatraid.rb
Associated revisions
Revision 516402c77f9c7d751c627db36885e12aaff62bf9
Fixing #1918 – facter —puppet always works
The problem was that Facter wasn’t telling Puppet to read your puppet.conf, so if you’d set vardir or libdir in it then you didn’t get the appropriate settings and thus not know where to find the facter plugins.
This is a bit of a ham-handed approach, but it always works.
Signed-off-by: Luke Kanies luke@madstop.com
History
Updated by James Turnbull over 1 year ago
- Status changed from Unreviewed to Accepted
- Assignee set to Luke Kanies
Luke?
Updated by Luke Kanies over 1 year ago
Fixing the markup.
Updated by Luke Kanies over 1 year ago
- Status changed from Accepted to Closed
I just tested this, and it works fine for me:
luke@phage $ ls -al $(puppet --configprint libdir)/facter
total 4
drwxr-xr-x 3 luke admin 102 2009-03-02 21:58 .
drwxr-xr-x 4 luke admin 136 2009-01-29 16:19 ..
-rw-r--r-- 1 luke admin 85 2009-03-02 21:58 testfact.rb
luke@phage $ cat $(puppet --configprint libdir)/facter/testfact.rb
require 'facter'
Facter.add("testfact") do
setcode do
"yep"
end
end
luke@phage $ facter | grep testfact
luke@phage $ facter --puppet | grep testfact
testfact => yep
luke@phage $
This 1.5.4 and Puppet 0.24.x HEAD.
Please reopen if you’re really convinced it’s a Facter problem and not a problem in your environment.
Updated by Miguel Armas over 1 year ago
I’m having the same problem here:
[root@xen0-devel ~]# rpm -q facter puppet ruby facter-1.5.4-1.el5 puppet-0.24.8-1.el5.1 ruby-1.8.5-5.el5_2.6 [root@xen0-devel ~]# ls -al $(puppet —configprint libdir)/facter total 24 drwxr-xr-x 2 root root 4096 Apr 10 10:07 . drwxr-xr-x 3 root root 4096 Nov 29 20:18 .. -rw-r—r— 1 root root 87 Apr 10 10:01 testfact.rb [root@xen0-devel ~]# cat $(puppet —configprint libdir)/facter/testfact.rb require ‘facter’
Facter.add(“testfact”) do
setcode do
"yep"
end
end
[root@xen0-devel ~]# facter —puppet | grep testfact [root@xen0-devel ~]#
This is a CentOS 5 host with latest puppet and facter from epel repo. How can I debug the problem? If it’s a bug in the RPM packages I will report it to EPEL
Updated by Luke Kanies over 1 year ago
- Status changed from Closed to Needs more information
Updated by Luke Kanies over 1 year ago
kuko wrote:
This is a CentOS 5 host with latest puppet and facter from epel repo. How can I debug the problem? If it’s a bug in the RPM packages I will report it to EPEL
Edit the Facter executable to print $LOAD_PATH after the ‘require “puppet”’ is called. If your Puppet libdir isn’t in the ruby loadpath, then that’s the problem. If it is, then, well, something even weirder is going on. But that’s what loading Puppet does for you — adds its libdir to your ruby Load path.
Hmm, I just realized – are you overriding the value of ‘libdir’ or some parent dir in your Puppet configuration? If so, that’s probably the problem; Facter doesn’t tell Puppet to load its configuration, and it would need so for that to work. Try adding ‘Puppet.parse_config’ after the ‘require “puppet”’‘ line in Facter, see if that fixes it.
It’s also worth just making sure your fact works:
ruby -rfacter .../path/to/fact.rb
And try loading the Puppet libs yourself:
ruby -rpuppet /path/to/facter | grep testfact
Updated by Ben Hughes over 1 year ago
adding ‘Puppet.parse_config’ after the ‘require “puppet”’‘ line works perfectly, however, I’m not modifying libdir, but some of the others:
[root@foo1-vm:~]# cat /etc/puppet/puppet.conf | grep -v "#" [main] logdir = /var/log/puppet vardir = /var/lib/puppet ssldir = /var/lib/puppet/ssl rundir = /var/run/puppet pluginsync = true factpath = /var/lib/puppet/lib/facter [puppetmasterd] templatedir = /var/lib/puppet/templates
The difference between the libdirs are:
with Puppet.parse_config
["/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/xml-simple-1.0.11", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/bin", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib", "/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/bin", "/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib", "/usr/local/lib/site_ruby/1.8", "/usr/local/lib/site_ruby/1.8/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.8", "/usr/lib/ruby/vendor_ruby/1.8/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/x86_64-linux", ".", "/var/puppet/lib"]
without
["/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/i18n-0.0.1", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/tzinfo-0.3.12", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/memcache-client-1.5.1", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/xml-simple-1.0.11", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/vendor/builder-2.1.2", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/bin", "/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib", "/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/bin", "/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib", "/usr/local/lib/site_ruby/1.8", "/usr/local/lib/site_ruby/1.8/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.8", "/usr/lib/ruby/vendor_ruby/1.8/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.8", "/usr/lib/ruby/1.8/x86_64-linux", ".", "/var/puppet/lib"]
which are the same!
(this is on debian etch, with Ruby 1.8.7, puppet 0.24.8, and facter 1.5.4)
Updated by Luke Kanies over 1 year ago
- Subject changed from facter --puppet doesn't do anything for me to facter --puppet doesn't work when puppet's vardir or libdir are modified
- Category set to binary
- Status changed from Needs more information to Accepted
- Target version set to 1.6.0
The libdir is usually in the vardir, so changing the vardir changes the libdir.
This is clearly the problem, and simply parsing the config file should suffice (although it’s not entirely trivial, since the method profile changes in master.
Updated by Luke Kanies over 1 year ago
- Status changed from Accepted to Ready for Checkin
- Assignee changed from Luke Kanies to James Turnbull
Fixed in the tickets/master/1918 branch in my repo.
Updated by James Turnbull over 1 year ago
- Status changed from Ready for Checkin to Code Insufficient
- Target version changed from 1.6.0 to 1.5.5
Can you rebase on 1.5.x please. Also what is – commit:“33fe2b63f363b1f1f823e9938de93f5aa94e8efd”? I don’t see a ticket for it???
Updated by James Turnbull over 1 year ago
- Assignee changed from James Turnbull to Luke Kanies
Updated by Luke Kanies over 1 year ago
- Status changed from Code Insufficient to Ready for Checkin
- Assignee changed from Luke Kanies to James Turnbull
Rebased.
And that commit didn’t seem like it deserved a ticket. It’s pretty small, just removes trailing colons from interface names.
Updated by James Turnbull over 1 year ago
- Status changed from Ready for Checkin to Closed
Until it caused a merge conflict… :)
Pushed in commit:“516402c77f9c7d751c627db36885e12aaff62bf9” in branch 1.5.x