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:

app/views/puppetclasses/_form.html.erb
<%= base_errors_for @puppetclass %>
<ul class="nav nav-tabs" data-tabs="tabs">
<li class="active"><a href="#primary" data-toggle="tab">Puppet Class</a></li>
<li><a href="#smart_class_param" data-toggle="tab">Smart Class Parameter</a></li>
<li><a href="#smart_vars" data-toggle="tab">Smart Variables</a></li>
</ul>
......
<div class="tab-pane active" id="primary">
<%= text_f f, :name %>
<%= multiple_checkboxes f, :environments, @puppetclass, Environment, :label => "Puppet Environments" %>
<%= text_f f, :environments, :value => @puppetclass.environments.to_sentence, :label=> 'Puppet Environments', :disabled => true %>
<%= multiple_checkboxes f, :hostgroups, @puppetclass, Hostgroup, :label => "Hostgroups" %>
</div>
<div class="tab-pane" id="smart_class_param">
<% if @puppetclass.class_params.empty? -%>
<div class="alert alert-message alert-success">
<a class="close" href="#" data-dismiss="alert">&times;</a>
<p><strong>This Puppet class has no parameters in its signature.</strong><br>
To update the class signature, go to the Puppet Classes page and select 'Import'.</p>
</div>
<% else -%>
<div class="control-group">
<label class="control-label">Filter By Environment</label>
<div class="controls">
<%= select_tag "environment_filter", options_from_collection_for_select(@puppetclass.environments, "id", "name"),
:include_blank => "All - (Not filtered)", :onchange=>'filterByEnvironment(this)'%>
</div>
</div>
<div class="tabbable tabs-left">
<ul class="nav nav-tabs smart-var-tabs span2" data-tabs="pills">
<% @puppetclass.class_params.each do |key| -%>
<li data-used-environments=<%= key.environments.map(&:to_s).to_json %>><a data-toggle="tab" id="pill_<%= key.to_s.gsub(' ','_') %>" href="#<%= key.to_s.gsub(' ','_') %>"><%= key %><span class="label label-important fr">&times;</span></a></li>
<% end -%>
</ul>
<div class="tab-content span9 smart-var-content">
<%= f.fields_for :class_params do |lookup_keys_form| %>
<%= render 'lookup_keys/fields', :f => lookup_keys_form %>
<% end %>
</div>
</div>
<% end -%>
</div>
<div class="tab-pane" id="smart_vars">
<% if @puppetclass.lookup_keys.empty? -%>
<div class="alert alert-message alert-warning">

Also available in: Unified diff