Ask Your Question
0

custom fact issue

asked 2015-07-24 11:30:45 -0600

nate gravatar image

i inherited some legacy code that uses the list of applied classes on a node to assign a "node type." this parses /var/lib/puppet/classes.txt as a fact ("puppet_classes").

the reworked node type fact looks roughly like this, which includes an example node type and classes:

https://gist.github.com/rockpapergoat...

the original is way longer and prone to failure.

the parse_classes method returns correct results when outside the Facter.add blocks but nothing inside. what am i missing?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-07-27 23:20:58 -0600

GregLarkin gravatar image

What version of Puppet are you using? If it's PE 3.[78], you could use the node classifier API to retrieve the node's classification: https://docs.puppetlabs.com/pe/latest/nc_classification.html#post-v1classifiednodesnameexplanation

Also, I can't figure out why that custom fact would be needed. Since the master already knows what classes have been assigned to the node, why does the node then parse the class list, build a fact, then send that fact value back to the master on the next run? What does the code do with that fact value, and how does it change the behavior of the compilation the next time the agent checks in?

Just curious if there might be an easier way to solve whatever problem required writing the code this way originally.

edit flag offensive delete link more

Comments

thanks, greg. we're on the open source 3.7.x series right now. i've solved the immediate issue to get these facts working, which allows some old code to hang around for awhile, but i'm working to replace the whole thing. it's way too complicated. legacy codebase, yo.

nate gravatar imagenate ( 2015-08-06 12:47:33 -0600 )edit

Glad you found a workaround for now, and it sounds like you're on the right path with an eye towards rewriting and simplifying the code. Keep posting here if you run into anything else!

GregLarkin gravatar imageGregLarkin ( 2015-08-06 14:45:52 -0600 )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

Stats

Asked: 2015-07-24 11:30:45 -0600

Seen: 87 times

Last updated: Jul 27 '15