Module: ForemanPuppet::EnvironmentsImport

Extended by:
ActiveSupport::Concern
Included in:
EnvironmentsController, PuppetclassesController
Defined in:
app/controllers/concerns/foreman_puppet/environments_import.rb

Instance Method Summary collapse

Instance Method Details

#import_environmentsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/concerns/foreman_puppet/environments_import.rb', line 11

def import_environments
  @changed = importer.changes

  if @importer.ignored_boolean_environment_names?
    warning(_('Ignored environment names resulting in booleans found. Please quote strings like true/false and yes/no in config/ignored_environments.yml'))
  end

  if !@changed['new'].empty? || !@changed['obsolete'].empty? || !@changed['updated'].empty?
    render 'foreman_puppet/common/_puppetclasses_or_envs_changed'
  else
    info_message = _('No changes to your environments detected')

    list_ignored(info_message, @changed['ignored']) if @changed['ignored'].present?

    info info_message
    redirect_to controller: controller_path
  end
end

#obsolete_and_newObject



30
31
32
33
34
35
36
37
# File 'app/controllers/concerns/foreman_puppet/environments_import.rb', line 30

def obsolete_and_new
  if (errors = PuppetClassImporter.new.obsolete_and_new(params[:changed])).empty?
    success _('Successfully updated environments and Puppet classes from the on-disk Puppet installation')
  else
    error _('Failed to update environments and Puppet classes from the on-disk Puppet installation: %s') % errors.to_sentence
  end
  redirect_to controller: controller_path
end