Ask Your Question
0

custom type: unexpected tLABEL on redhat linux, but not on debian

asked 2017-08-30 02:30:24 -0600

uherbst gravatar image

updated 2017-08-30 07:51:25 -0600

DarylW gravatar image

Hi, First thing: I'm not the ruby guy.....

I wrote some custom types on my debian PC with a puppet standalone installation. (puppet-4.8.2-5). Testing my custom types was successful.

After moving this types to our production environment (Oracle Linux 7 - that's a RHEL7-clone), Puppetserver-5.0.0, I got:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Could not autoload puppet/type/solace_messagevpn: /etc/puppetlabs/code/environments/development/modules/daivb_solace/lib/puppet_x/solacelib/helper.rb:244: syntax error, unexpected tLABEL
    def self.list_instances(objtype: 'unknown' )
                                    ^ at /etc/puppetlabs/code/environments/development/manifests/solace_daiinfra1.pp:9:3 on node solace_daiinfra1

Obviously, puppet (or the ruby behind puppet) has a syntax issue with my code.

Any ideas how to fix it ?

The idea behind this function definition is:

def self.list_instances(objtype: 'unknown')

this should be a function with a named argument, calling would be something like: list_instances(objtype: 'bridge')

Ok, now I discovered how to run irb with Puppetservers jruby.

See difference:

1 . "normal irb"

/opt/puppetlabs/puppet/bin/irb
irb(main):001:0> def uli(xx:)
irb(main):002:1> puts "xx: #{xx}"
irb(main):003:1> end 
=> :uli
irb(main):005:0> uli xx: 123
xx: 123 
=> nil

2 . jpython irb:

 puppetserver irb
 irb(main):001:0> def uli(xx:)
 irb(main):002:1>  puts "xx: #{xx}"
 irb(main):003:1>  end
 SyntaxError: (irb):1: syntax error, unexpected tLABEL
 def uli(xx:)
                ^

=> Ok, That's my error. Does anyone know, which "normal" ruby version corresponds to puppetservers jruby-version ?

Uli

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-08-31 01:40:44 -0600

uherbst gravatar image

As DarylW has commented, this is indeed an isssue with different ruby features in different versions.

Puppetserver uses jruby, and that has a ruby version 1.9something.

I tried to use named parameters - the ruby 2.0 (and newer) solution is to use something like

def uli(xx:)

the ruby1.9 solution (that also works for ruby 2.0 and newer) is a hash.

This is completely described here: link text

With that change implemented, it is working fine on puppetserver.

edit flag offensive delete link more
0

answered 2017-08-30 08:08:11 -0600

DarylW gravatar image

updated 2017-08-30 08:22:00 -0600

On a fresh install of puppet5 on centos7, and then installing puppetserver.noarch 0:5.0.0-1.el7, it shows me the following

# /opt/puppetlabs/bin/puppetserver ruby --version
jruby 1.7.27 (1.9.3p551) 2017-05-11 8cdb01a on OpenJDK 64-Bit Server VM 1.8.0_141-b16 +jit [Linux-amd64]

The version of jruby is 1.7.27, which corresponds with the 'ruby' version of 1.9.3p551

The version of ruby installed with puppet, however, is as follows

# /opt/puppetlabs/puppet/bin/ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]

There are differences in the accepted syntax between ruby 1.9 and ruby 2.4.

The specific error is described in this stackoverflow answer

I'm not familiar enough with ruby to get you past your error. What are you trying to with the : char in the parameter definition?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-08-30 02:30:24 -0600

Seen: 29 times

Last updated: Aug 31