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

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using https://tickets.puppetlabs.com. See the following page for information on filing tickets with JIRA:

Feature #4350

Should be able to interpolate variables in classes containing dash/hyphen

Added by Alan Harder almost 6 years ago. Updated over 5 years ago.

Status:DuplicateStart date:07/23/2010
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:parser
Target version:-
Affected Puppet version:0.25.5 Branch:
Keywords:

We've Moved!

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


Description

class test-class {
  $var = 'foo'
}
node default {
  include test-class
  notify { "value is ${test-class::var}": }
}

Running above test case on 2.6.0 / ruby 1.8.7 / Solaris 10 results in:

/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/parser_support.rb:172:in `on_error'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/util/autoload.rb:79:in `_racc_yyparse_c'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/lexer.rb:483:in `scan'
/opt/csw/lib/ruby/1.8/racc/parser.rb:152:in `_racc_yyparse_c'
/opt/csw/lib/ruby/1.8/racc/parser.rb:152:in `__send__'
/opt/csw/lib/ruby/1.8/racc/parser.rb:152:in `yyparse'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/parser_support.rb:181:in `parse'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/resource/type_collection.rb:164:in `perform_initial_import'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/node/environment.rb:75:in `known_resource_types'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/resource/type_collection_helper.rb:5:in `known_resource_types'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:425:in `initvars'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:180:in `initialize'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:18:in `new'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:18:in `compile'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/util.rb:180:in `benchmark'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:112:in `main'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:35:in `run_command'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application.rb:301:in `run'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application.rb:398:in `exit_on_fail'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application.rb:301:in `run'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute'
/opt/csw/bin/puppet:4
/opt/csw/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:21:in `compile'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/util.rb:180:in `benchmark'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:112:in `main'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application/apply.rb:35:in `run_command'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application.rb:301:in `run'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application.rb:398:in `exit_on_fail'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/application.rb:301:in `run'
/opt/csw/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute'
/opt/csw/bin/puppet:4
Could not parse for environment production: Syntax error at 'class::var'; expected '}' at foo.pp:6 on node ...

Workaround of course is to not use dash/hyphen in class names…


Related issues

Related to Puppet - Feature #3987: Allow ${var} with curlies everywhere Accepted 06/10/2010
Related to Puppet - Feature #17260: Optional deprecation warning for hyphens in names Closed
Duplicates Puppet - Bug #902: Qualified-variable names cannot contain hyphens (but clas... Duplicate
Duplicates Puppet - Bug #5268: hyphen in class name messes with qualified variables Re-opened 11/11/2010

History

#1 Updated by Markus Roberts almost 6 years ago

  • Status changed from Unreviewed to Rejected

This didn’t work in 0.25.x either (and IIRC much earlier) but it just quietly failed, with the example above giving:

notice: value is ${test-class::var}
notice: //Node[default]/Notify[value is ${test-class::var}]/message: defined 'message' as 'value is ${test-class::var}'

instead of the expected:

notice: value is foo
notice: //Node[default]/Notify[value is foo]/message: defined 'message' as 'value is foo'

While this is easy to figure out in a notice, it could be much more confusing in an internal use case, quietly resulting in unexpected behaviour rather than failing.

It may be better to allow interpolation of ‘–’ class names, but until then it is better to fail than do something unexpected.

#2 Updated by Markus Roberts almost 6 years ago

  • Tracker changed from Bug to Feature
  • Subject changed from Cannot reference variable in class containing dash/hyphen to Should be able to interpolate variables in classes containing dash/hyphen
  • Status changed from Rejected to Needs Decision
  • Affected Puppet version changed from 2.6.0 to 0.25.5

Rather than creating a new ticket I decided to repurpose this one. There had been some talk at one point about gradually phasing out class names containing ‘–’; if that’s going to be done we should make it explicit; if not, this use-case should be fixed.

#3 Updated by Nigel Kersten over 5 years ago

  • Status changed from Needs Decision to Duplicate

Also available in: Atom PDF