Thanks to Saurabh pointing me in the right direction, the solution I found
to getting basic custom facts to work were as follows:-

1.  On the puppetmaster in your modules directory create a facts module with
subdirectory files. In this add any of your custom .rb scripts

# ls /etc/puppet/modules/facts/files
day_of_week.rb
hardware_platform.rb    # = wiki example


2. On the puppetmaster in /etc/puppet/puppet.conf I added:-
    pluginsync = true
    factpath = $vardir/facts    #vardir = /var/lib/puppet

3. On the puppetmaster in /etc/puppet/fileserver.conf I added:-
[facts]
path /var/lib/puppet/facts
  allow yourdomain.com    # I think these 3 lines are optional
  deny *.evil.example.com   #           "     "
  allow 10.0.0.0/24              #           "   "

4. On the server I added the file  /etc/profile.d/facter.sh containing
export FACTERLIB=/var/lib/puppet/facts
Not entirely sure if this step is necessary but I saw it on another posting

5. On the client I didn't seem to need to do anything to the config files
and the only change needed to pick this up was add the --factsync param to
puppetd
All being well you should see something like the following on fhe client:-

# puppetd -vt --factsync
info: Retrieving facts
notice: /File[/var/lib/puppet/facts/day_of_week.rb]/ensure: created
notice: /File[/var/lib/puppet/facts/hardware_platform.rb]/ensure: created
info: Loading fact day_of_week
info: Loading fact hardware_platform
info: Caching catalog at /var/lib/puppet/localconfig.yaml
notice: Starting catalog run

To then access the variables that you have defined simply refer to them in
your manifest eg. $day_of_week or $hardware_platform

It is probably worth noting that this may not be the best way of doing
things. The example used in the wiki using the 'custom' module I could not
get to work without file errors relating to /facts. I'm sure there is added
benefits in using the wiki example but hopefully this may get someone over
the first hurdle

Paul





2009/5/28 paul matthews <[email protected]>

> Superb, thanks for that. I think my confusion was missing the point that
> you need a specific module for facts pointed to by factpath  rather than
> tacking on a plugins/facter directory under an existing module
>
> 2009/5/28 Saurabh Verma <[email protected]>
>
>
>> paul matthews wrote:
>> > Hi,
>> > I'm attempting to create a custom fact to tell me the day of the week
>> > ( to be used as a file suffix for vmware snapshots). I've followed the
>> > wiki which advises deploying facts via modules for releases >0.24. As
>> > I understand this means :-
>> >
>> >    1. creating a plugins/facter directory under an existing (or new
>> >       module)
>> >    2. dropping in your ruby based facter (.rb) script to that directory
>> >    3.  adding the following to /etc/puppet/puppet.conf on the master
>> >
>> > [main]
>> > pluginsync = true
>> > factpath = $vardir/lib/facter
>> >
>> > Aftre this things get a bit hazy for me. The Adding Facts wiki page
>> > http://reductivelabs.com/trac/puppet/wiki/AddingFacts talks about :-
>> >
>> > >> Create a directory called facter/ somewhere, and set the
>> > environment variable $RUBYLIB to its parent. You can then run facter,
>> > and it will import your code:
>> >
>> > >> host:~$ mkdir -p ~/lib/ruby/facter ; export RUBYLIB=~/lib/ruby
>> > >> host:/tmp$ cp /path/to/hardware_platform.rb $RUBYLIB/facter
>> > >> host:/tmp$ facter hardware_platform
>> > >> SUNW,Sun-Blade-1500
>> >
>> This is to test your scripts , its nothing related to custom facts
>> distribution per se.
>> > Do I need to do this or is this deprecated with modules? Also, what
>> > does the factpath do? Does that need to exist on master and clients.
>> > The final step is to run puppetd with --factsync on (I guess) a
>> > client. On mine it returns an error
>> >
>> > # puppetd -vt --factsync
>> > info: Retrieving facts
>> > err: /File[/var/lib/puppet/facts]: Failed to generate additional
>> > resources during transaction: Fileserver module 'facts' not mounted
>> >
>> Did you configure you fileserver.conf  on puppetmaster for "facts"
>> module i.e did you add following in your fileserver.conf ?
>>
>> [facts]
>>   path /var/lib/puppet/facts
>>
>> here "/var/lib/puppet/facts" is your path to "facts" file server module
>> on  puppetmaster where you will put your custom scripts that will sync
>> to puppet client  and gets distributed to $factdest.  factpath is  the
>> option to puppet which  tells where to look for the facts and by
>> default  this is set as same as $factdest .
>> > In short, as you can probably tell, I don't really know what I'm doing
>> > so any help would be great
>> >
>> > Cheers
>> > Paul
>> > --
>> > Paul Matthews
>> > ----------------------------------------------------------------------
>> >
>> > >
>>
>>
>> >>
>>
>
>
> --
> Paul Matthews
> ----------------------------------------------------------------------
>



-- 
Paul Matthews
----------------------------------------------------------------------

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to