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

Bug #12387

nagios_service improperly resolving $title ?

Added by Justin Honold about 2 years ago. Updated 4 months ago.

Status:ClosedStart date:02/02/2012
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Keywords: Affected URL:
Branch:

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

Take, for example, the following snippet:

nagios_service { 'check_ssh':
  use                 => 'my-service',
  check_command       => 'check_ssh',
  hostgroup_name      => 'my-hostgroup',
  service_description => "$title",
}

I would expect that to set the ‘service_description’ field to ‘check_ssh’. Instead, it sets it to ‘nagios::alerts’, the name of the CLASS in which the declaration is contained. Is this a bug?

History

#1 Updated by Chris Price about 2 years ago

  • Status changed from Unreviewed to Rejected

I believe that what you are dealing with here is just a matter of variable scope, and expectations thereof. Simple resources do not make their attributes accessible as variables. There is, however, a $title variable available from the parent scope (which, in this case, is indeed the scope of the class declaration).

#2 Updated by Justin Honold about 2 years ago

Yes, this was a case of me assuming, then hoping, that they exposed attributes in the same way as defines. Thanks for the clarification!

#3 Updated by Peter Burkholder about 2 years ago

  • Status changed from Rejected to Re-opened

I just ran into a similar issue. I think the language guide needs to be updated. At http://docs.puppetlabs.com/guides/language_guide.html#resources it states clearly:

“The field before the colon is the resource’s title, which must be unique and can be used to refer to the resource in other parts of the Puppet configuration.” and the rest of the document doesn’t clarify the scoping issues with the $title variable.

Is there a place in the docs that does make that clarification?

#4 Updated by Daniel Pittman about 2 years ago

  • Project changed from Puppet to Puppet Documentation

#5 Updated by Daniel Pittman about 2 years ago

Peter Burkholder wrote:

I just ran into a similar issue. I think the language guide needs to be updated. At http://docs.puppetlabs.com/guides/language_guide.html#resources it states clearly:

“The field before the colon is the resource’s title, which must be unique and can be used to refer to the resource in other parts of the Puppet configuration.” and the rest of the document doesn’t clarify the scoping issues with the $title variable.

Is there a place in the docs that does make that clarification?

I don’t know. What I have done is bumped this over to the documentation issue tracker, and our awesome documentation person Nick Fagerlund will doubtless take a look at it shortly.

Thanks for the feedback, and bouncing this open again – that sort of feedback on what makes the documentation useful is really helpful to us.

#6 Updated by Nick Fagerlund 4 months ago

  • Status changed from Re-opened to Closed

Language reference rewrite should have solved this. If not, we’ll see it again in the new ticketing system.

Also available in: Atom PDF