Share data between invocations of custom function?

asked 2017-01-01 16:19:39 -0500

Tim Landscheidt gravatar image

I have a custom function on a Puppet 3.8.5 master that reads a YAML file and returns some value. On the first invocation, the contents of the file are read into a class variable (@@variable) and subsequent invocations use that value unless the file has changed.

This concept works nicely, but feels unsupported. Is there a documented way/best practice to share data between invocations of a custom function? Are there separate patterns for sharing data for the lifetime of the catalog run for one node vs. the lifetime of the puppetmaster?

edit retag flag offensive close merge delete

Comments

Have you tried upgrading to PP 4.x?

Kai Burghardt gravatar imageKai Burghardt ( 2017-01-02 18:19:26 -0500 )edit

I've had similar concerns. If we had multiple things that would need to call the aws api and get back the json representation of all of the instances, and do $thing based on those instances, we would prefer to cache that info for some time. I have a feeling it is a general 'ruby' issue, not puppet

DarylW gravatar imageDarylW ( 2017-01-03 08:49:47 -0500 )edit

@Kai Burghardt: Upgrading is currently not an option, but looking at https://docs.puppet.com/guides/custom_functions.html I also don't see how that would change anything, the documentation does not seem to address this topic in any version.

Tim Landscheidt gravatar imageTim Landscheidt ( 2017-01-03 20:03:00 -0500 )edit