From 175b4e07b67deebfa511461d3fce54bfa50f142c Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Thu, 19 May 2022 12:16:39 -0700 Subject: [PATCH] use instance debug instead of Puppet.debug The instance method prepends resource information to the debug message. Example of Puppet.debug: Debug: Searching for hostgroup with name dev and title dev Example of instance #debug: Debug: Foreman_hostgroup[dev](provider=rest_v3): Making get request to ... --- lib/puppet/provider/foreman_hostgroup/rest_v3.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/foreman_hostgroup/rest_v3.rb b/lib/puppet/provider/foreman_hostgroup/rest_v3.rb index 8b29458d9..c2ee7d4e3 100644 --- a/lib/puppet/provider/foreman_hostgroup/rest_v3.rb +++ b/lib/puppet/provider/foreman_hostgroup/rest_v3.rb @@ -16,7 +16,7 @@ def exists? end def create - Puppet.debug("Creating Foreman Hostgroup #{resource[:name]} with parent #{resource[:parent_hostgroup]}") + debug("Creating Foreman Hostgroup #{resource[:name]} with parent #{resource[:parent_hostgroup]}") if resource[:parent_hostgroup] && parent_hostgroup_id.nil? raise Puppet::Error, @@ -44,7 +44,7 @@ def create end def destroy - Puppet.debug("Destroying Foreman Hostgroup #{resource[:name]} with parent #{resource[:parent_hostgroup]}") + debug("Destroying Foreman Hostgroup #{resource[:name]} with parent #{resource[:parent_hostgroup]}") path = "api/v2/hostgroups/#{id}" r = request(:delete, path) @@ -59,7 +59,7 @@ def destroy def flush return if @property_flush.empty? - Puppet.debug "Calling API to update properties for #{resource[:name]}" + debug "Calling API to update properties for #{resource[:name]}" path = "api/v2/hostgroups/#{id}" r = request(:put, path, {}, { hostgroup: @property_flush }.to_json) @@ -107,7 +107,7 @@ def hostgroup else search_name end - Puppet.debug("Searching for hostgroup with name #{search_name} and title #{search_title}") + debug("Searching for hostgroup with name #{search_name} and title #{search_title}") r = request(:get, path, search: %(title="#{search_title}" and name="#{search_name}")) raise Puppet::Error, "Error making GET request to Foreman at #{request_uri(path)}: #{error_message(r)}" unless success?(r) @@ -141,7 +141,7 @@ def parent_hostgroup path = 'api/v2/hostgroups' search_title = resource[:parent_hostgroup] search_name = resource[:parent_hostgroup_name] || search_title.split('/').last - Puppet.debug("Searching for parent hostgroup with name #{search_name} and title #{search_title}") + debug("Searching for parent hostgroup with name #{search_name} and title #{search_title}") r = request(:get, path, search: %(title="#{search_title}" and name="#{search_name}")) raise Puppet::Error, "Error making GET request to Foreman at #{request_uri(path)}: #{error_message(r)}" unless success?(r)