antoineco / aco-tomcat

Puppet module for Tomcat
https://forge.puppet.com/aco/tomcat
Other
9 stars 26 forks source link

template fails to parse - undefined method 'encode' #83

Closed EqUaTe closed 7 years ago

EqUaTe commented 7 years ago

Fails to run with following error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template tomcat/common/server.xml/000_header.erb:
  Filepath: /etc/puppet/environments/testing/modules/tomcat/templates/common/server.xml/000_header.erb
  Line: 8
  Detail: undefined method `encode' for "8005":String
 at /etc/puppet/environments/testing/modules/tomcat/manifests/config.pp:117 on node [redacted]
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

This is with as simple an element as 'include tomcat'

Puppet version 3.8.7, stdlib is latest, concat is 2.2.0, archive is 1.3.0, OS is Debian Stretch (9), with puppetlabs repo versions of puppet.

Not really sure why this is happening, so any pointers would be appreciated.

antoineco commented 7 years ago

encode is a String method from the Ruby stdlib: https://ruby-doc.org/core-2.2.0/String.html#method-i-encode

May I ask what Ruby version you're using?

EqUaTe commented 7 years ago

Ruby version on the system I'm testing with is: ruby 2.1.5p273, which in turn reminds me.. Test system is actually Debian 8.

antoineco commented 7 years ago

I tried with the following fresh Debian 8 environment:

# puppet --version
3.7.2

# ruby --version
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]

# puppet module install aco/tomcat
/etc/puppet/modules
└─┬ aco-tomcat (v1.8.1)
  ├── puppet-archive (v1.3.0)
  ├─┬ puppetlabs-concat (v2.2.1)
  │ └── puppetlabs-stdlib (v4.20.0)
  └── puppetlabs-firewall (v1.9.0)

# puppet module apply -e 'include tomcat'
Notice: Compiled catalog for localhost in environment production in 0.48 seconds
[...]
Notice: /Stage[main]/Tomcat::Service::Package/Service[tomcat8]: Triggered 'refresh' from 7 events
Notice: Finished catalog run in 111.25 seconds

Any idea how I could reproduce? Did you double check that Puppet is using the Ruby version you're expecting?

EqUaTe commented 7 years ago

I'll have to check how to confirm which version of ruby puppet is absolutely using as I'm not sure - the system also has 1.9.1 installed, but /usr/bin/ruby is 2.1.5. I am using puppet 3.8.7 from the puppetlabs repo, so that /might/ make a difference.. The other thing that I suppose could be different is that I'm running it with --noop in an agent setup, but I wouldn't expect it to..

Shall investigate further tomorrow.

EDIT: definitely using 2.1.5:

facter rubyversion rubysitedir rubysitedir => /usr/local/lib/site_ruby/2.1.0 rubyversion => 2.1.5

EqUaTe commented 7 years ago

Ok, so if I follow your example (replacing puppet module apply with puppet apply -e 'include tomcat' --noop), it works. I'm going to remove the local module and strip the remote node manifest right back now, it appears that there is a conflict of some kind.

antoineco commented 7 years ago

puppet and facter will both use the Ruby version configured in your current shell, that's why you see Ruby 2.1.5, and no error.

When puppet-agent starts it may use some unexpected Ruby version, as I've witnessed myself in the past. Add something like which ruby > /tmp/puppet_ruby_ver at the beginning of your puppet-agent init script and check the content of the generated file just to be sure.

EqUaTe commented 7 years ago

Right, agent/master mode, a node manifest of:

node 'hostname' {
  include tomcat
}

fails with the encode error. Could the ruby version on the master be an issue?

On the node seeing this, puppet is run from cron, but I'm getting this error when running puppet agent manually: puppet agent -ovt --no-daemonize --noop

antoineco commented 7 years ago

Yes in a master/node setup the master compiles the catalog, so it could be the issue.

EqUaTe commented 7 years ago

Ruby on the master is 1.8. I do have newer versions, but they are part of scl and similar, so somewhat awkward to use within Apache. Additionally, all the documentation around using passenger explicitly refers to ruby1.8 (even the latest version), which I find a little disappointing.

antoineco commented 7 years ago

I think that setup has been long deprecated in favour of the clojure-based Puppet Server, that's why all references are so old :)

EqUaTe commented 7 years ago

Yes, and that move is on my list, but sadly I'm not quite there yet :-( I'm trying a few things to get the master using ruby193 from scl, which /might/ help.

EqUaTe commented 7 years ago

Ok, going to abandon this for now - I have a very small set of hosts with tomcat on, so I am better spending the time porting my env to puppet 4 or 5.

Thanks for your help though! :)

antoineco commented 7 years ago

You're welcome, good luck with your upgrade!