Foreman 3 Upgrade - undefined method '#environment

Problem:
After upgrading Foreman from 2.5.4 to 3.0.1 to 3.10 we cannot use the variable @host.environment anymore. When using it in provisioning templates or template in a parameter of a puppet class it results in the error undefined method ‘#environment’ for Host::Managed::Jail (Host::Managed). Till foreman 2.5.4 this was possible without any problems. More Details you can find in the attachment foreman3_undefined_method_environment.log (28.2 KB)

Expected outcome:
Can use a variable which represents the environment in templates, no matter if its @host.environment or something similar. But i cant find anything in the docs, that this shouldnt work anymore

Foreman and Proxy versions:
Tested Foreman 3.0.1 and Foreman 3.1.0

Distribution and version:
Rhel7.9

Other relevant data:

Hi @chr1s, Foreman 3.1 is only compatible with foreman_puppet version 2.0.x - foreman_puppet 1.0.x is compatible with Foreman 3.0. Can you please double-check whether the versions match?

Of course. Currently the following packages are installed:

# rpm -qa | grep foreman | sort
foreman-3.1.0-1.el7.noarch
foreman-debug-3.1.0-1.el7.noarch
foreman-dynflow-sidekiq-3.1.0-1.el7.noarch
foreman-postgresql-3.1.0-1.el7.noarch
foreman-proxy-3.1.0-1.el7.noarch
foreman-selinux-3.1.0-1.el7.noarch
foreman-service-3.1.0-1.el7.noarch
foreman-telemetry-3.1.0-1.el7.noarch
tfm-rubygem-foreman_column_view-0.4.0-5.fm2_5.el7.noarch
tfm-rubygem-foreman_puppet-2.0.0-1.fm3_1.el7.noarch
tfm-rubygem-foreman_remote_execution-5.0.1-1.fm3_1.el7.noarch
tfm-rubygem-foreman_remote_execution_core-1.4.8-1.el7.noarch
tfm-rubygem-foreman-tasks-5.2.0-1.fm3_1.el7.noarch
tfm-rubygem-foreman-tasks-core-0.3.6-1.fm2_5.el7.noarch
tfm-rubygem-foreman_templates-9.1.0-1.fm2_6.el7.noarch

Looking good, thanks - I was asking because it said foreman_puppet 1.0.5 in your log :slight_smile: @ezr-ondrej any idea what that is about? Do we miss anything in the plugin?

ok sorry. i tested with foreman 3.0.1 and foreman 3.1.0. Seems that i send the logs from foreman 3.0.1 instead of 3.1.0. Here we go with the correct log :slight_smile: foreman3.1_undefined_method_environment.log (28.4 KB)

Ok, my fault. This was annouced in your deprecations in the docs (Foreman :: Manual):

  • @host.environmenthost_puppet_environment

Oh, happy you’ve figured that out, I’ve got that open, but didn’t get to it over xmass :frowning:

Was that you custom template where you’ve been hitting it?

Yes, we’ve custom templates and used “@host.environment” in some smart class parameters.