Issue #7267 has been updated by Ben Hughes.

Category set to language
Status changed from Unreviewed to Accepted
Keywords set to DSL

Ah yes, this does look like a bug in the Ruby DSL.

To simply the problem. This is the define (as I see it) in Puppet land:

<pre>
[ben@paresthesia:~]% cat foo.pp                   
define instance(
    $ensure = "present" ,
    $ip ,
    $foo = "bar" )
{
    notice( "I am a banana" )
}
[ben@paresthesia:~]% puppet apply --verbose foo.pp
info: Applying configuration version '1305069315'
notice: Finished catalog run in 0.02 seconds
</pre>

And this is it in Ruby DSL land:

<pre>
[ben@paresthesia:~]% cat puppetruby.rb

define "instance",
  :ensure => "present",
  :ip,
  :foo => "bar" do

  notice ["I am a banana"] 

end

[ben@paresthesia:~]% puppet apply --noop --verbose puppetruby.rb
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/parser/parser_support.rb:191:in 
`parse_ruby_file': (eval):5:in `parse_ruby_file': compile error (SyntaxError)
(eval):4: syntax error, unexpected ',', expecting tASSOC
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/parser/parser_support.rb:148:in 
`parse'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/node/environment.rb:161:in 
`perform_initial_import'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/node/environment.rb:84:in 
`known_resource_types'
        from 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
 `synchronize'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/node/environment.rb:81:in 
`known_resource_types'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/resource/type_collection_helper.rb:5:in
 `known_resource_types'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/parser/compiler.rb:430:in 
`initvars'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/parser/compiler.rb:188:in 
`initialize'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/parser/compiler.rb:18:in `new'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/parser/compiler.rb:18:in 
`compile'
        from 
/Users/ben/Puppetlabs/repos//puppet/lib/puppet/indirector/catalog/compiler.rb:78:in
 `compile'
</pre>

It shouldn't care about the :ip variable not having an argument, but does.

This may just be a nuance of the DSL, but if it is, we definitely need to 
document it.

----------------------------------------
Bug #7267: Ruby DSL definitions must have required parameters at the beginning 
or a syntax error occurs
https://projects.puppetlabs.com/issues/7267

Author: Philip Gardner
Status: Accepted
Priority: Normal
Assignee: 
Category: language
Target version: 
Affected Puppet version: 
Keywords: DSL
Branch: 


Order seems to matter when declaring a new definition in the Ruby DSL:

This:
<pre>
define "instance", :ensure => "present", :owner => "owner", :group => "group", 
:platform => "jdk", :platform_version => "1.6.0_11", :platform_arch => 
"x86_64", :appserver => "resin", :appserver_version => "3.1.0", :appserver_arch 
=> "x86_64", :family => "services", :ip, :parentdir => "/usr/local/someplace/" 
do
</pre>

cause this error:
<pre>
err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
(eval):227:in `parse_ruby_file': compile error
(eval):125: syntax error
define "instance", :ensure => "present", :owner => "owner", :group => "owner", 
:platform => "jdk", :platform_version => "1.6.0_11", :platform_arch => 
"x86_64", :appserver => "resin", :appserver_version => "3.1.0", :appserver_arch 
=> "x86_64", :ip, :family => "services", :parentdir => "/usr/local/someplace/" 
do
</pre>

However, if you move the :ip parameter to the beginning of the list, `define 
"instance", :ip, :ensure => "present"...`, there is no reported error and 
catalog compilation succeeds.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to