On Monday, November 17, 2014 8:47:28 AM UTC-6, Jonathan Cohen wrote:
>
> 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?
>
>
>

You have written a *custom* fact, which is a plugin to Facter.  You have 
installed it where Facter expects to find *external* facts, which are 
standalone programs that Facter runs to produce fact values.  Custom facts 
should be contained in Puppet modules 
<https://docs.puppetlabs.com/guides/plugins_in_modules.html>, and will be 
synced to the correct location on clients automatically via the 
"pluginsync" mechanism.


John

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ef0f2384-877f-4b57-a187-054c489c721e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to