Adding the fact to a module is a recommended method, which is what you are doing. That file will get synced to a client first, then facts are collected, then the catalog is generated using those facts, so this ensures the correct order of operations.
The only thing you may want to tweak is what module the fact is in. I put most of mine in my profile module since that's part of my controlrepo, but you could make a personal_facts module if you wanted to consolidate multiple custom facts in one place. I wouldn't prematurely optimize this, it's easy to change later. On Tue, Dec 27, 2016 at 10:34 AM Denny Fuchs <denny.schi...@gmail.com> wrote: > hi, > > thanks for the reply :-) > > I added a custom fact via modules/role/lib/facter/role.rb > > Facter.add(:role) do > setcode do > host = Facter.value(:fqdn) > declared_role = Facter.value(host) > declared_role.nil? ? 'base' : declared_role > end > end > > I copied that piece of code and it works, if I change "base" to > "mysql_server". In the end, I can execute on the mon.example.com "facter > -p role" and I get "mysql_server" back. So far so good. I saw many examples > how to set the fact, but mostly I dislike them (e.g. create file > /etc/system_role ... hardcoded in the Facter.add .... ). What I miss: how > can I set the fact (role in my case) via hiera, or via node manifest ? > > > cu denny > > > > > > > > > -- > > > 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/2840db66-1c91-43c9-8e96-47f52b38f7e6%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/2840db66-1c91-43c9-8e96-47f52b38f7e6%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > For more options, visit https://groups.google.com/d/optout. > > > -- Rob Nelson -- 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/CAC76iT_XWnDqK4Hzx-F49tcjYMpjvcfGRwo%2BVKhsLM3f1xiF7w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.