I have a custom Puppet function that takes a file, checks the contents of the file and returns a hash depending on the content:
Puppet::Functions.create_funct