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
More about pluginsync can be found here: plugins in modules