Project

General

Profile

Actions

Feature #15972

open

Foreman fact name used for 'update_environment_from_facts' should be parametrizable

Added by Robert Heinzmann over 7 years ago. Updated over 7 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Facts
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

New Puppet Code does not automatically export the "Environment" fact anymore. See http://projects.theforeman.org/issues/2205.

To allow clients to switch environments permanently when using Foreman as ENC and to support reporting the puppet client environment in Foreman dashboard, the ticket suggests adding a custom fact, which works for us.

However puppet has a very bad behaviour in 3.x, as custom facts can overwrite ENC set environment. See https://tickets.puppetlabs.com/browse/PUP-2630 for reference.

Currently the name of the fact used for "update_environment_from_facts" is hard coded to :environment, which causes a lot of side effects caused by the puppet bug above.

To provide reasonable compatibility, Foreman should support a new config option to define the fact name which will be used for "update_environment_from_facts" (e.g. puppet_environment). This way, clients side effects by setting the custom fact "environment" can be avoided while allowing the user who want's to "use update_environment_from_facts", to use this functionality by using another fact name as source for update_environment_from_facts.

The default value can be "environment" to provide 100% backward compatibility.


Files

puppet 3 environment overwrite.png View puppet 3 environment overwrite.png 10.8 KB Environment Test Cases Puppet 3.8.6 Robert Heinzmann, 08/03/2016 06:50 PM

Related issues 1 (0 open1 closed)

Related to Foreman - Bug #2205: Environment doesn't exist in Puppet 3+ facts YAMLResolved02/13/2013Actions
Actions #1

Updated by Robert Heinzmann over 7 years ago

This works for us:

require 'puppet'

Facter.add(:environment) do
  setcode do
    Puppet[:environment]
  end
end

But we would rather use:

require 'puppet'

Facter.add(:puppet_environment) do
  setcode do
    Puppet[:environment]
  end
end

and specify the fact used for 'update_environment_from_facts' to be set to 'puppet_environment'. This avoids side effects.

Actions #2

Updated by Robert Heinzmann over 7 years ago

Attached the test results of the Puppet 3.8.6 environment selection using

- CMD line arguments to puppet agent 
- custom facts specifying environment
- Puppet ENC specifying environment

!puppet 3 environment overwrite.png!

Actions #3

Updated by Robert Heinzmann over 7 years ago

  • Related to Bug #2205: Environment doesn't exist in Puppet 3+ facts YAML added
Actions #4

Updated by Marek Hulán over 7 years ago

  • Category set to Facts
Actions #5

Updated by Robert Heinzmann over 7 years ago

Actually I tested some more with Puppet 3.8 with Puppetserver 1.1.x and Agent.

With a dynamic environment fact like this:

require 'puppet'

Facter.add(:environment) do
  setcode do
    Puppet[:environment]
  end
end

The behaviour of puppet is "chaotic".

puppet agent --environment feature_xyz
enc: environment: production
  • Hiera: uses environment "feature_xyz" for hierdata content
  • Puppet Server: uses environment "production" for code

This is really a bad idea. So providing the possibility to rename the fact, is really important.

Actions

Also available in: Atom PDF