puppetlabs / puppetlabs-tagmail

Report processor that sends email based on events in reports
Apache License 2.0
8 stars 39 forks source link

compatibility with Puppet 8 #244

Open corporate-gadfly opened 1 year ago

corporate-gadfly commented 1 year ago

Describe the Bug

I wasn't ready to make the move to Puppet 8 yet, however, my yum repository mirror mistakenly showed puppetserver-8.0.0-1.el8.noarch.rpm and a yum update updated the puppet version.

Expected Behavior

tagmail should run with Puppet 8

Steps to Reproduce

Steps to reproduce the behavior:

  1. Install Puppet 8 RPM on CentOS 8 Stream
  2. Logs will show an error:
    2023-04-26T10:20:33.989-04:00 ERROR [qtp277425324-72] [puppetserver] Puppet Could not autoload puppet/reports/tagmail: no such file to load -- net/smtp
    org/jruby/RubyKernel.java:1057:in `require'
    uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/rubygems/core_ext/kernel_require.rb:85:in `require'
    /etc/puppetlabs/code/environments/production/modules/tagmail/lib/puppet/reports/tagmail.rb:6:in `<main>'
    org/jruby/RubyKernel.java:1091:in `load'
    /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:78:in `load_file'
    /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:182:in `load'
    /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/instance_loader.rb:54:in `block in loaded_instance'
    /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/concurrent/lock.rb:10:in `synchronize'
    /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/instance_loader.rb:49:in `loaded_instance'
    /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/instance_loader.rb:27:in `block in instance_load'
    /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/report/processor.rb:52:in `block in processors'

Environment

corporate-gadfly commented 1 year ago

Worth mentioning that no errors after downgrading puppetserver to version puppetserver-7.11.0-1.el8.noarch.rpm.

corporate-gadfly commented 1 year ago

If it helps any, looks like net-smtp is no longer a default gem in Ruby 3.1.

mdechiaro commented 10 months ago

@corporate-gadfly I came across these problems and this issue, and I found a solution.

You'll need the net-smtp gem installed a puppetserver_gem. You can do this in hiera with stdlib module.

---
classes:
- stdlib
stdlib::manage::create_resources:
  package:
    net-smtp: {ensure: installed, provider: puppetserver_gem}

Also, this requires an extra path to ruby-load-path in /etc/puppetlabs/puppetserver/conf.d/puppetserver.conf.

from:

ruby-load-path: [/opt/puppetlabs/puppet/lib/ruby/vendor_ruby]

to:

ruby-load-path: [/opt/puppetlabs/puppet/lib/ruby/vendor_ruby, /opt/puppetlabs/puppet/cache/lib]

I found this path fix via #102

Matty-uk commented 8 months ago

I tried installing net-smtp package via gem and making the /etc/puppetlabs/puppetserver/conf.d/puppetserver.conf change but it is still failed for me after upgrading to Puppet Server 8.

What did work was getting Puppet to install via gem via a module of mine, not sure why it worked, but it did. $gemreqpacks = ['net-smtp'] package { $gemreqpacks: ensure => present, provider => 'puppetserver_gem', }