Jonathan Cohen
2014-Nov-17 14:47 UTC
[Puppet Users] Issue getting new custom fact to work in OS X
I'm trying to get a new custom fact working in OS X. Source information is
from:
https://github.com/grahamgilbert/grahamgilbert-mac_facts/blob/master/lib/facter/mac_admin_users.rb
Here is the process that I went through.
I added the .rb file to /etc/facter/facts.d/mac_admin_users.rb and modified
the permissions to match existing custom facts.
-rwxr-xr-x 1 root wheel 272 Nov 17 08:11 mac_admin_users.rb
When I run
sudo facter
I get the following error:
/etc/facter/facts.d/mac_admin_users.rb: line 3: syntax error near unexpected
token `:mac_admin_users'
/etc/facter/facts.d/mac_admin_users.rb: line 3: `Facter.add(:mac_admin_users)
do'
Fact file /etc/facter/facts.d/mac_admin_users.rb was parsed but returned an
empty data set
I tried to get more information with
sudo facter --debug
but that did not produce anything different.
Here is my file:
#mac_admin_users.rb
#require 'facter'
Facter.add(:mac_admin_users) do
confine :kernel => "Darwin"
setcode do
admins = Facter::Util::Resolution.exec("dscl . -read /Groups/admin
GroupMembership")
admins.gsub('GroupMembership: ','').gsub(' ',
', ')
end
end
I also tested the dscl command on its own just to make sure I didn't have
an error there but that worked.
I do have another custom fact running that outputs the time machine status
and that is working.
I'm new to implementing custom facts and I really don't know where to
start. Is there something that I have missed in the syntax?
System Details:
OS X version 10.10
facter version: 2.3.0
MacBook Pro Retina
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/8f4ce3e3-f9ff-44ba-a8a0-facddecb4d40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.