Project

General

Profile

« Previous | Next » 

Revision f8d94608

Added by Amos Benari over 11 years ago

  • ID f8d946082e58b60213a27ded3e1e5f5373d976de

fixes #832 - adds parameterized class support

Credits:
This patch is based on the original work of Olivier Favre
<> many many thanks!

This patch adds the following features
  • import class parameters, and try to understand their types
  • support a complex matrix of environments, puppet classes and their
    signature - each class can have a different set of parameters per environment.
  • adds an ignore yaml file 'config/ignored_environments.yml.sample' file were
    users can add regexp or class names that the importer should ignore.
    common usage case for this is classes such as ::config, ::install etc.
  • introduce a new type of smart variable - parameterized.
  • adds complex data types to smart vars, arrays, hashes, json, yaml etc are all supported now.

in order to use the new ENC format for puppet 2.6.5+ you should enable the
Parametrized_Classes_in_ENC and Enable_Smart_Variables_in_ENC within Foreman Settings

This is the initial patch just to get param classes support in, follow-up patches
would include a better UI and the relevant UI updates to host edit page etc.

Signed-off-by: Ohad Levy <>

View differences:

lib/foreman/controller/environments.rb
def import_environments
begin
@changed = Environment.importClasses params[:proxy]
opts = params[:proxy].blank? ? { } : { :url => SmartProxy.find(params[:proxy]).try(:url) }
@importer = PuppetClassImporter.new(opts)
@changed = @importer.changes
rescue => e
if e.message =~ /puppet feature/i
error "We did not find a foreman proxy that can provide the information, ensure that you have at least one Proxy with the puppet feature turned on."
......
end
end
if @changed["new"].size > 0 or @changed["obsolete"].size > 0
if @changed["new"].size > 0 or @changed["obsolete"].size > 0 or @changed["updated"].size > 0
render "common/_puppetclasses_or_envs_changed"
else
notice "No changes to your environments detected"
......
end
def obsolete_and_new
if (errors = ::Environment.obsolete_and_new(params[:changed])).empty?
if (errors = ::PuppetClassImporter.new.obsolete_and_new(params[:changed])).empty?
notice "Successfully updated environments and puppetclasses from the on-disk puppet installation"
else
error "Failed to update the environments and puppetclasses from the on-disk puppet installation<br/>" + errors.join("<br>")
......
redirect_to :controller => controller_path
end
end
end

Also available in: Unified diff