Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autofs_version fact throws exception on mac OS X #68

Closed
jgreen210 opened this issue Jun 16, 2017 · 3 comments
Closed

autofs_version fact throws exception on mac OS X #68

jgreen210 opened this issue Jun 16, 2017 · 3 comments

Comments

@jgreen210
Copy link
Contributor

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.8.1
  • Ruby: ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin15]
  • Distribution: El Capitan
  • Module version: 3.0.1, 3.0.2 and presumably 3.0.0

How to reproduce (e.g Puppet code you use)

Run puppet apply with any puppet manifests. Don't need to be using autofs resources, just need to have puppet/autofs in your Puppetfile (and have done a pluginsync).

What are you seeing

 DEBUG [71b964ab] 	Debug: Facter: searching for custom facts in /opt/puppetlabs/puppet/cache/lib/facter.
 DEBUG [71b964ab] 	Debug: Facter: fact "agent_specified_environment" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: fact "apt_has_updates" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: fact "apt_package_updates" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: fact "apt_reboot_required" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: fact "apt_security_updates" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: fact "apt_update_last_success" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: fact "apt_updates" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: fact "archive_windir" resolved to null and will not be added.
 DEBUG [71b964ab] 	Debug: Facter: executing command: /bin/sh -c /usr/sbin/automount -V 2>&1
 DEBUG [71b964ab] 	Debug: Facter: /usr/sbin/automount: illegal option -- V
 DEBUG [71b964ab] 	Debug: Facter: process exited with status code 1.
 DEBUG [71b964ab] 	Debug: Facter: process exited with status code 1.
 DEBUG [71b964ab] 	Error: Facter: error while resolving custom fact "autofs_version": undefined method `[]' for nil:NilClass

What behaviour did you expect instead

No crash, and autofs_version fact returning something like nil or empty string.

Output log

Any additional information you'd like to impart

This new autofs_version fact was added in this PR:

#33

@jgreen210
Copy link
Contributor Author

jgreen210 commented Jun 16, 2017

It looks like the right thing to do is to "confine" this to Linux (since the regex is linux specific):

https://docs.puppet.com/facter/3.6/custom_facts.html#confining-facts

If ever want to support mac's automount, then it looks like can add a fact confined to Darwin kernel next to this one.

I've not tested this:

diff --git a/lib/facter/autofs.rb b/lib/facter/autofs.rb
index 309eb3c..6e0ab68 100644
--- a/lib/facter/autofs.rb
+++ b/lib/facter/autofs.rb
@@ -1,4 +1,5 @@
 Facter.add(:autofs_version) do
+  confine :kernel => 'Linux'
   setcode do
     if Facter::Util::Resolution.which('automount')
       autofs_version_command = 'automount -V 2>&1'

jgreen210 pushed a commit to jgreen210/puppet-jenkins that referenced this issue Jun 16, 2017
jgreen210 pushed a commit to jgreen210/puppet-autofs that referenced this issue Jun 16, 2017
jgreen210 pushed a commit to jgreen210/puppet-autofs that referenced this issue Jun 16, 2017
@jgreen210
Copy link
Contributor Author

Closing the above PR since still get an error:

 DEBUG [6b42cc02] 	Debug: Facter: executing command: /bin/sh -c /usr/sbin/automount -V 2>&1
 DEBUG [6b42cc02] 	Debug: Facter: /usr/sbin/automount: illegal option -- V
 DEBUG [6b42cc02] 	Debug: Facter: process exited with status code 1.
 DEBUG [6b42cc02] 	Debug: Facter: process exited with status code 1.
 DEBUG [6b42cc02] 	Error: Facter: error while resolving custom fact "autofs_version": undefined method `[]' for nil:NilClass
 DEBUG [6b42cc02] 	Debug: Facter: fact "autofs_version" resolved to null and will not be added.

I can look at this some more next week.

@jgreen210
Copy link
Contributor Author

Reopened PR #69 - the changes do work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant