Ask Your Question

correct ordering: class depending on custom fact

asked 2013-12-12 13:52:25 -0500

Thynan gravatar image

updated 2013-12-12 14:09:37 -0500


I have the following problem: I have a class "classA" which reads some values from hiera. The server who executes "classA" needs to have a custom fact "custom-role", so that "classA" gets the values from the correct hiera file.

So my plan was to add an external fact via puppet, before the class gets executed, like so:

#the external fact which assigns role to server
    ensure => file,
    content => 'role=some_role',
    mode => '644',
#the class which gets data from hiera, but only if the server has the correct role
include classA

#the external ...
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-12-13 07:11:50 -0500

dgmorales gravatar image

Well, I'm pretty sure (and you may know that already) that facts are only read before catalog compilation, so your code installs the fact, but is not aware of it until the next run.

You could use a ruby fact. Those already get synced before the agent runs. Even if you never touched ruby, it's pretty trivial to write one like you need. There's even an example of a "role" fact in that doc.

edit flag offensive delete link more


OK, using ruby facts instead of external facts sounds like a nice compromise. Thanks!

Thynan gravatar imageThynan ( 2013-12-15 03:40:01 -0500 )edit

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: 2013-12-12 13:52:25 -0500

Seen: 119 times

Last updated: Dec 13 '13