A better enc script to contact foreman?

Hi All,

I've written a new version of Foreman ENC script (the script which runs on
your puppet master to query foreman for information).

Changes are:

  • Prior to asking Foreman for ENC yaml, it would upload the new host facts
    to foreman, this would ensure that the facts are updated as soon as they are
    upload to your puppet master,
    and only the relevant ones (for example, it wont import old facts for hosts
    that might not be around any more).
    This is important if you do any search based lookups from within your puppet
    manifest (e.g. using
    https://github.com/ohadlevy/puppet-foreman/blob/master/foreman/lib/puppet/parser/functions/foreman.rb),
    which ensures you get the latest fact information.

  • Caching of results, in case foreman is not running/timeouts etc, it would
    simply read the last good yaml output from foreman

This is fairly new script, so there is a good chance that there are some
bugs, but if you are willing to give it a try, please note a few things:

  1. do not have any other fact importer running at the same time (rake task
    or push facts cron job).
  2. the enc script would write by default to /var/lib/puppet/yaml/foreman
    directory to store the cached results, by default puppet user should have
    write access to that directory.
  3. if you are running storeconfigs, you dont need to upload your facts (as
    its already done via puppet), so you could simply comment out line #75
    (upload_facts line).

Script at https://gist.github.com/1011921

Thanks,
Ohad