The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Bug #22622

Puppet fails when facter loads a script based external fact that doesn't return any output

Added by Martijn Grendelman over 2 years ago. Updated over 2 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Martijn Grendelman% Done:

0%

Category:-
Target version:1.7.4
Keywords:windows Affected Facter version:1.7.3
Branch:https://github.com/puppetlabs/facter/pull/567

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com


Description

After upgrading Puppet agent on a Windows Server 2003 instance to 3.3.0 (from Puppetlabs-supplied puppet-3.3.0.msi), both Facter and Puppet did no longer work:

Facter:

Running Facter on demand ...
Failed to load feature test for root: undefined method `each_line' for nil:NilClass
Error: undefined method `each_line' for nil:NilClass

Puppet:

Running Puppet agent on demand ...
Failed to load feature test for root: undefined method `each_line' for nil:NilClass
C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/parser.rb:73:in `parse': undefined method `each_line' for nil:NilClass (NoMethodError)
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/parser.rb:120:in `results'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/directory_loader.rb:61:in `block in load'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/directory_loader.rb:55:in `each'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/directory_loader.rb:55:in `load'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/composite_loader.rb:10:in `block in load'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/composite_loader.rb:10:in `each'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/composite_loader.rb:10:in `load'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/collection.rb:109:in `load'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/collection.rb:84:in `fact'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter/util/collection.rb:139:in `value'
        from C:/Program Files/Puppet Labs/Puppet/facter/lib/facter.rb:112:in `block (2 levels) in singletonclass'
        from C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/defaults.rb:4:in `default_diffargs'
        from C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/defaults.rb:183:in `<module:Puppet>'
        from C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/defaults.rb:1:in `<top (required)>'
        from C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet.rb:109:in `<module:Puppet>'
        from C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet.rb:29:in `<top (required)>'
        from C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Program Files/Puppet Labs/Puppet/puppet/lib/puppet/util/command_line.rb:12:in `<top (required)>'
        from C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Program Files/Puppet Labs/Puppet/sys/ruby/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/Program Files/Puppet Labs/Puppet/puppet/bin/puppet:3:in `<main>'

Downgrading to 3.2.4 fixed the problem and restored functionality. The problem does not occur on Windows Server 2008 with Puppet 3.3.0.


Related issues

Related to Facter - Bug #23058: facter crashes when parsing nil output from custom facts ... Duplicate
Duplicated by Facter - Bug #23243: Dies when empty, executable file placed in facts.d Duplicate

History

#1 Updated by Josh Cooper over 2 years ago

  • Project changed from Puppet to Facter
  • Category deleted (windows)
  • Status changed from Unreviewed to Needs More Information
  • Assignee set to Martijn Grendelman
  • Keywords set to windows
  • Affected Facter version set to 1.7.3

This issue is due to facter 1.7.3 adding external executable fact support. Do you happen to have an executable script (likely powershell) sitting in %ALLUSERSPROFILE%\Application Data\PuppetLabs\facter\facts.d (if you’re running as an Administrator), or ~\.facter\facts.d (if you’re not)? This wouldn’t have been an issue previously, because facter 1.7.2 and earlier ignored external executable scripts on windows.

#2 Updated by Josh Cooper over 2 years ago

I’ve been able to create the problem by creating an empty .txt or .ps1 file in the locations mentioned earlier, though I am curious to know if that is the same issue that you are seeing?

#3 Updated by Josh Cooper over 2 years ago

  • Status changed from Needs More Information to Investigating
  • Target version set to 1.7.4

Steps to reproduce:

C:\Program Files (x86)\Puppet Labs\Puppet\bin>mkdir c:\ProgramData\PuppetLabs\facter\facts.d
C:\Program Files (x86)\Puppet Labs\Puppet\bin>touch c:\ProgramData\PuppetLabs\facter\facts.d\foo.ps1
C:\Program Files (x86)\Puppet Labs\Puppet\bin>puppet --version
Failed to load feature test for root: undefined method `each_line' for nil:NilClass
C:/Program Files (x86)/Puppet Labs/Puppet/facter/lib/facter/util/parser.rb:73:in
 `parse': undefined method `each_line' for nil:NilClass (NoMethodError)
        from C:/Program Files (x86)/Puppet Labs/Puppet/facter/lib/facter/util/parser.rb:137:in `results'
        from C:/Program Files (x86)/Puppet Labs/Puppet/facter/lib/facter/util/directory_loader.rb:61:in `block in load'
        from C:/Program Files (x86)/Puppet Labs/Puppet/facter/lib/facter/util/directory_loader.rb:55:in `each'
...

Also get the same result if you create an empty foo.bat

#4 Updated by Martijn Grendelman over 2 years ago

Yes, I have several external facts, one of which is a .bat file.

#5 Updated by Josh Cooper over 2 years ago

  • Status changed from Investigating to Accepted

#6 Updated by Klavs Klavsen over 2 years ago

I just saw this exact same issue, with puppet-3.3.1 on windows – where I had an sql-instances-list.exe file in the c:\documents and settings\all users\application data\puppetlabs\facter\facts.d\ folder.

#7 Updated by Rob Reynolds over 2 years ago

If I had to guess, I would say that spaces are the issue….

#8 Updated by Klavs Klavsen over 2 years ago

my sql-instances-list.exe file, just returns: mssqlinstances=

as output – and that breaks it on 2003. on win2008 it works fine.

and afaik – that’s valid facter_d output?

#9 Updated by Rob Reynolds over 2 years ago

Can you do me a favor and run the exe just by itself on the 2003 box to see what it returns?

#10 Updated by Josh Cooper over 2 years ago

  • Subject changed from Puppet 3.3.0 and Facter completely broken on Windows Server 2003 to Puppet fails when facter loads a script based external fact that doesn't return any output

This affects windows (powershell, bat, etc) and unix (.sh). It’s because Facter::Util::Resolution.exec returns nil, and we call each_line on it.

#11 Updated by Ethan Brown over 2 years ago

  • Branch set to https://github.com/puppetlabs/facter/pull/564

#12 Updated by Josh Cooper over 2 years ago

  • Status changed from Accepted to Merged - Pending Release
  • Branch changed from https://github.com/puppetlabs/facter/pull/564 to https://github.com/puppetlabs/facter/pull/567

Merged in commit 3bdc0bf to be released in 1.7.4

#13 Updated by Melissa Stone over 2 years ago

  • Status changed from Merged - Pending Release to Closed

Release in Facter 1.7.4-rc1

Also available in: Atom PDF