Project

General

Profile

« Previous | Next » 

Revision fd30481b

Added by Ohad Levy over 11 years ago

  • ID fd30481bf1947ae34b3984959a2b19c085e26d2a

fixes #2124 - only include classes from the host current environment.

This patch introduce a new setting, which decide how would foreman
address a mismatch between host and hostgruop environments.

for example, when puppet classes (directly or indirectly via hostgroups) that do not
belongs to the host current environment, they would silently removed from
the class list that foreman suggests as an ENC.

NOTE: this only effects the new ENC output (/w param classes).

View differences:

app/models/classification.rb
def puppetclass_ids
return @puppetclass_ids if @puppetclass_ids
@puppetclass_ids = host.host_classes.pluck(:puppetclass_id)
@puppetclass_ids += HostgroupClass.where(:hostgroup_id => hostgroup.path_ids).pluck(:puppetclass_id) if hostgroup
@puppetclass_ids
ids = host.host_classes.pluck(:puppetclass_id)
ids += HostgroupClass.where(:hostgroup_id => hostgroup.path_ids).pluck(:puppetclass_id) if hostgroup
@puppetclass_ids = if Setting['remove_classes_not_in_environment']
EnvironmentClass.where(:environment_id => host.environment_id, :puppetclass_id => ids).
pluck('DISTINCT puppetclass_id')
else
ids
end
end
def classes
lib/foreman/default_settings/loader.rb
set('Parametrized_Classes_in_ENC', "Should Foreman use the new format (2.6.5+) to answer Puppet in its ENC yaml output?", param_enc),
set('enc_environment', "Should Foreman provide puppet environment in ENC yaml output? (this avoids the mismatch error between puppet.conf and ENC environment)", true),
set('use_uuid_for_certificates', "Should Foreman use random UUID's for certificate signing instead of hostnames", false),
set('update_environment_from_facts', "Should Foreman update a host's environment from its facts", false)
set('update_environment_from_facts', "Should Foreman update a host's environment from its facts", false),
set('remove_classes_not_in_environment',
"When Host and Hostgroup have different environments should all classes be included (regardless if they exists or not in the other environment)", false)
].compact.each { |s| create s.update(:category => "Puppet")}
[ set('oauth_active', "Should foreman use OAuth for authorization in API", false),
test/fixtures/settings.yml
category: Auth
default: "SSL_CLIENT_VERIFY"
description: "Environment variable containing the verification status of a client SSL certificate"
attribute31:
name: remove_classes_not_in_environment
category: Puppet
default: false
description: "When Host and Hostgroup have different environments should all classes be included (regardless if they exists or not in the other environment)"

Also available in: Unified diff