Ask Your Question

define fact during puppet apply

asked 2014-03-28 07:45:45 -0600

dOps gravatar image

I am trying to define a custom fact using a rb file. When placed in facts directory this file generates the fact correctly. Now what I want to do is propagate this file during puppet apply and then use the fact generated by this file during puppet apply

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-03-28 18:19:37 -0600

Stefan gravatar image

updated 2014-05-11 15:56:21 -0600

Facts are gathered before building the catalog so if you ship the fact with a file resource, the fact will appear on your agent when the catalog is already built. As a result it will only be available in your manifests during the second puppet run.

To accomplish your goal puppet uses a pluginsync mechanism that will copy custom facts onto the agent (together with custom types, custom providers, custom features, custom functions, etc) before building the catalog. All you have to do is place your .rb file in an arbitrary module directoy under lib/facter, so e.g. /etc/puppet/modules/foo/lib/facter/my_fact.rb. If you are using a master <-> agent setup, the agent will sync the plugins from the master but it also works the same way when running puppet apply.

More about pluginsync can be found here: plugins in modules

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-03-28 07:45:45 -0600

Seen: 216 times

Last updated: May 11 '14