The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Feature #7076

Error message isn't very clear about where problem is

Added by micah - over 3 years ago. Updated almost 2 years ago.

Status:DuplicateStart date:04/12/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:error reporting
Target version:-
Affected Puppet version: Branch:
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

I received this error:

err: Could not run Puppet configuration client: Parameter ensure failed: Invalid value "ensure". Valid values are present, absent.  at line 31

indisputably, a bug in my manifests, but where? Fortunately, I was able to find it, but most puppet messages like this give you a clue where you failed so you have a much easier time of finding it.


Related issues

Duplicates Puppet - Bug #16208: parameter validation errors aren't very clear Closed 08/31/2012

History

#1 Updated by Ben Hughes over 3 years ago

  • Status changed from Unreviewed to Needs More Information

What was at line 31 and where was the actual bug please?

#2 Updated by micah - over 3 years ago

this was a module in which I had a selector which if true set ‘ensure’ to be whatever the $ensure variable was set to. I had left off the $ in front of the variable name ‘$ensure’ so I ended up setting ‘ensure => ensure’. The fix is as below:

diff --git a/manifests/service/imap.pp b/manifests/service/imap.pp
index 063231d..b703db4 100644
--- a/manifests/service/imap.pp
+++ b/manifests/service/imap.pp
@@ -16,7 +16,7 @@ define nagios::service::imap(
       ensure => $ensure;
     "imaps_${name}_${tls_port}":
       ensure => $tls ? {
-        true => ensure,
+        true => $ensure,
         default => 'absent'
         };
   }

#3 Updated by Ben Hughes over 3 years ago

  • Status changed from Needs More Information to Accepted

So, this is built up by lib/puppet/parameter/value_collection.rb:

  # Verify that the passed value is valid.
  def validate(value)
    return if empty?

    unless @values.detect { |name, v| v.match?(value) }
      str = "Invalid value #{value.inspect}. "

      str += "Valid values are #{values.join(", ")}. " unless values.empty?

      str += "Valid values match #{regexes.join(", ")}." unless regexes.empty?

      raise ArgumentError, str
    end
  end

Which is called from lib/puppet/type.rb’s

    property = self.newattr(name)

    if property
      begin
        # make sure the parameter doesn't have any errors
        property.value = value
      rescue => detail
        error = Puppet::Error.new("Parameter #{name} failed: #{detail}")
        error.set_backtrace(detail.backtrace)
        raise error
      end
    end

But I’m not sure if either of those two functions have the calling type or access to it’s name to report on. Pointing it at some devs to hopefully get some more light on if this is possible.

#4 Updated by Dominic Cleal almost 2 years ago

  • Status changed from Accepted to Duplicate

Fixed now in #16208.

Also available in: Atom PDF