From 4802d2d06178af8ad2d65e586abda893f39c68d6 Mon Sep 17 00:00:00 2001 From: Alexandros Afentoulis Date: Mon, 26 Jun 2023 16:40:41 +0300 Subject: [PATCH] Don't lookup `lookup_options` key Prevent recursive queries for `lookup_options`; idea stolen from https://github.com/dalen/puppet-puppetdbquery/issues/115. --- lib/puppet/functions/puppetdb_lookup_key.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/puppet/functions/puppetdb_lookup_key.rb b/lib/puppet/functions/puppetdb_lookup_key.rb index 344d79c..84520b2 100644 --- a/lib/puppet/functions/puppetdb_lookup_key.rb +++ b/lib/puppet/functions/puppetdb_lookup_key.rb @@ -15,6 +15,10 @@ def puppetdb_lookup_key(key, options, context) return context.cached_value(key) if context.cache_has_key(key) + if key == "lookup_options" + context.not_found + end + if !key.end_with?('::_nodequery') && nodequery = call_function('lookup', "#{key}::_nodequery", 'merge' => 'first', 'default_value' => nil) # Support specifying the query in a few different ways query, fact, sort = case nodequery