Project

General

Profile

Bug #20378

foreman is not able to identify agent environment in puppet 5 and sets it to the default

Added by Elisiano Petrini over 1 year ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Facts
Target version:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

I was having the following issue:
- the node had the correct environment set in puppet.conf
- the node was in the right environment in foreman
- I ran puppet on the node and in foreman it was moved to the default environment

I've noticed that in my setup the /opt/puppetlabs/server/data/puppetserver/yaml/node/$fqdn.yaml is not getting generated (yaml/facts/$fqdn.yaml is there).
I don't know why it doesn't get generated but it seems that upgrading to puppet 5 that file stopped being written.

As pointed out by gwmngilfen, the above file is used in the classifier script in case the environment is not amongst the facts ( https://github.com/theforeman/puppet-foreman/blob/master/files/external_node_v2.rb#L119-L130 )

Currently the variable `name` which defines the environment is follows ( https://github.com/theforeman/foreman/blob/develop/app/services/puppet_fact_parser.rb#L64 )

    name = facts[:environment] || Setting[:default_puppet_environment]

I have disabled "ENC environment" setting (because I want the agent to be able to specify a different env for testing features). So I'm not sure how the behavior should be in case the setting is enabled but a simple workaround for this would be

   name = facts[:environment] || facts[:agent_specified_environment] || Setting[:default_puppet_environment]

I tested the above on 1.15.2 and it works as expected.


Related issues

Related to Foreman - Tracker #15096: Puppet 5 supportClosed2016-05-19

Associated revisions

Revision dcd0ac39 (diff)
Added by Michael Moll over 1 year ago

Refs #20378 - update node.rb for Puppet5 env fact

Revision 503e91b0 (diff)
Added by Elisiano Petrini over 1 year ago

Fixes #20378 - Puppet 5 environment detection

History

#1 Updated by The Foreman Bot over 1 year ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4687 added

#2 Updated by Greg Sutcliffe over 1 year ago

Just to add, it seems that in Puppet 4 (or maybe earlier) the facts sent from the agent started including "agent_specified_environment" but we didn't use it in node.rb, leading to a fallback on the node file created by the puppetmaster. So it seems like a "happy" coincidence we've not hit this sooner.

Michael, do you now if this is a known change in Puppet 5? I'm not so familiar with the changes...

#3 Updated by Michael Moll over 1 year ago

I've noticed that in my setup the /opt/puppetlabs/server/data/puppetserver/yaml/node/$fqdn.yaml is not getting generated

Michael, do you now if this is a known change in Puppet 5?

It is: https://docs.puppet.com/puppetserver/latest/release_notes.html#deprecation-puppet-5-no-longer-writes-yaml-node-caches

#4 Updated by Michael Moll over 1 year ago

#5 Updated by Michael Moll over 1 year ago

  • Legacy Backlogs Release (now unused) set to 240

#6 Updated by Greg Sutcliffe over 1 year ago

Thanks Michael, presumably we'll want to update node.rb to account for that as well? Do you want a separate issue for that?

#7 Updated by The Foreman Bot over 1 year ago

  • Assignee set to Michael Moll
  • Pull request https://github.com/theforeman/puppet-foreman/pull/577 added

#8 Updated by Elisiano Petrini over 1 year ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#9 Updated by Ewoud Kohl van Wijngaarden 10 months ago

  • Bugzilla link set to 1535591

Also available in: Atom PDF