foreman_puppet 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +61 -7
  3. data/app/controllers/concerns/foreman_puppet/environments_import.rb +1 -1
  4. data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +1 -1
  5. data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +1 -1
  6. data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +3 -10
  7. data/app/controllers/concerns/foreman_puppet/parameters/puppetclass_lookup_key.rb +2 -2
  8. data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +4 -0
  9. data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +4 -0
  10. data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +4 -0
  11. data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +4 -0
  12. data/app/controllers/foreman_puppet/config_groups_controller.rb +4 -0
  13. data/app/controllers/foreman_puppet/puppet_smart_proxies_controller.rb +4 -0
  14. data/app/controllers/foreman_puppet/puppetclass_lookup_keys_controller.rb +2 -2
  15. data/app/controllers/foreman_puppet/puppetclasses_controller.rb +3 -2
  16. data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
  17. data/app/helpers/foreman_puppet/hosts_helper.rb +15 -0
  18. data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +2 -2
  19. data/app/models/concerns/foreman_puppet/extensions/host.rb +19 -8
  20. data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +5 -5
  21. data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +2 -2
  22. data/app/models/concerns/foreman_puppet/extensions/report.rb +18 -0
  23. data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +1 -1
  24. data/app/models/concerns/foreman_puppet/extensions/user.rb +19 -12
  25. data/app/models/foreman_puppet/environment_class.rb +1 -1
  26. data/app/models/foreman_puppet/host_class.rb +1 -1
  27. data/app/models/foreman_puppet/host_puppet_facet.rb +4 -3
  28. data/app/models/foreman_puppet/puppetclass.rb +13 -1
  29. data/app/services/foreman_puppet/puppet_class_importer.rb +14 -14
  30. data/app/views/foreman_puppet/common/_puppetclasses_or_envs_changed.html.erb +62 -0
  31. data/app/views/foreman_puppet/environments/index.html.erb +1 -1
  32. data/app/views/foreman_puppet/environments/welcome.html.erb +1 -1
  33. data/app/views/foreman_puppet/puppetclasses/_classes.html.erb +1 -1
  34. data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +1 -1
  35. data/app/views/foreman_puppet/puppetclasses/index.html.erb +1 -1
  36. data/app/views/hosts/_form_puppet_enc_tab.html.erb +1 -1
  37. data/app/views/hosts/select_multiple_environment.html.erb +1 -1
  38. data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +2 -2
  39. data/lib/foreman_puppet.rb +2 -2
  40. data/lib/foreman_puppet/engine.rb +7 -3
  41. data/lib/foreman_puppet/register.rb +4 -3
  42. data/lib/foreman_puppet/version.rb +1 -1
  43. data/locale/Makefile +1 -1
  44. data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
  45. data/locale/en/foreman_puppet.po +18 -6
  46. data/locale/foreman_puppet.pot +19 -3
  47. data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +1 -1
  48. data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +1 -1
  49. data/test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb +32 -0
  50. data/test/controllers/foreman_puppet/environments_controller_test.rb +1 -1
  51. data/test/factories/foreman_puppet_factories.rb +3 -0
  52. data/test/integration/foreman_puppet/puppetclass_js_test.rb +3 -0
  53. data/test/models/foreman_puppet/host_puppet_facet_test.rb +34 -1
  54. data/test/models/foreman_puppet/host_test.rb +1 -1
  55. data/test/models/foreman_puppet/provisioning_template_test.rb +16 -16
  56. data/test/models/foreman_puppet/report_test.rb +21 -0
  57. data/test/models/foreman_puppet/user_test.rb +29 -0
  58. data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +159 -161
  59. data/test/unit/foreman_puppet/puppet_class_importer_test.rb +13 -1
  60. metadata +48 -42
  61. data/locale/en/foreman_puppet.edit.po +0 -911
  62. data/locale/en/foreman_puppet.po.time_stamp +0 -0
@@ -3,19 +3,26 @@ module ForemanPuppet
3
3
  module User
4
4
  extend ActiveSupport::Concern
5
5
 
6
- def visible_environments
7
- authorized_scope = Environment.unscoped.authorized(:view_environments)
8
- authorized_scope = authorized_scope
9
- .joins(:taxable_taxonomies)
10
- .where('taxable_taxonomies.taxonomy_id' => taxonomy_ids[:organizations] + taxonomy_ids[:locations])
11
- result = authorized_scope.distinct.pluck(:name)
12
- if User.current.admin?
13
- # Admin users can also see Environments that do not have any organization or location, even when
14
- # organizations and locations are enabled.
15
- untaxed_environments = Environment.unscoped.where.not(id: TaxableTaxonomy.where(taxable_type: 'ForemanPuppet::Environment').distinct.select(:taxable_id)).pluck(:name)
16
- result += untaxed_environments
6
+ included do
7
+ prepend PatchedMethods
8
+ end
9
+
10
+ module PatchedMethods
11
+ def visible_environments
12
+ authorized_scope = ForemanPuppet::Environment.unscoped.authorized(:view_environments)
13
+ authorized_scope = authorized_scope
14
+ .joins(:taxable_taxonomies)
15
+ .where('taxable_taxonomies.taxonomy_id' => taxonomy_ids[:organizations] + taxonomy_ids[:locations])
16
+ result = authorized_scope.distinct.pluck(:name)
17
+ if ::User.current.admin?
18
+ # Admin users can also see Environments that do not have any organization or location, even when
19
+ # organizations and locations are enabled.
20
+ untaxed_env_ids = TaxableTaxonomy.where(taxable_type: 'ForemanPuppet::Environment').distinct.select(:taxable_id)
21
+ untaxed_environments = ForemanPuppet::Environment.unscoped.where.not(id: untaxed_env_ids).pluck(:name)
22
+ result += untaxed_environments
23
+ end
24
+ result
17
25
  end
18
- result
19
26
  end
20
27
  end
21
28
  end
@@ -6,7 +6,7 @@ module ForemanPuppet
6
6
  belongs_to :puppetclass, inverse_of: :environment_classes
7
7
  belongs_to :puppetclass_lookup_key, inverse_of: :environment_classes, class_name: 'ForemanPuppet::PuppetclassLookupKey'
8
8
  validates :puppetclass_lookup_key_id, uniqueness: { scope: %i[environment_id puppetclass_id] }
9
- validates :puppetclass_id, :environment_id, presence: true
9
+ validates :puppetclass, :environment, presence: true
10
10
  after_destroy :delete_orphaned_lookup_keys
11
11
 
12
12
  scope :parameters_for_class, lambda { |puppetclasses_ids, environment_id|
@@ -6,7 +6,7 @@ module ForemanPuppet
6
6
  include Authorizable
7
7
 
8
8
  validates_lengths_from_database
9
- belongs_to :puppetclass
9
+ belongs_to :puppetclass, class_name: 'ForemanPuppet::Puppetclass'
10
10
  belongs_to :host_puppet_facet
11
11
  has_one :host, through: :host_puppet_facet
12
12
 
@@ -6,7 +6,7 @@ module ForemanPuppet
6
6
  include Facets::Base
7
7
  include ForemanPuppet::HostCommon
8
8
 
9
- has_many :host_classes, dependent: :destroy
9
+ has_many :host_classes, dependent: :destroy, class_name: 'ForemanPuppet::HostClass'
10
10
  has_many :puppetclasses, through: :host_classes
11
11
 
12
12
  validates :environment_id, presence: true, unless: ->(facet) { facet.host.puppet_proxy_id.blank? }
@@ -18,10 +18,11 @@ module ForemanPuppet
18
18
  type ||= 'puppet'
19
19
  return unless type == 'puppet'
20
20
 
21
+ facet = host.puppet || host.build_puppet
21
22
  if Setting[:update_environment_from_facts]
22
- host.set_non_empty_values parser, [:environment]
23
+ facet.environment = parser.environment if parser.environment.present?
23
24
  elsif parser.environment.present?
24
- self.environment ||= parser.environment
25
+ facet.environment ||= parser.environment
25
26
  end
26
27
 
27
28
  # if proxy authentication is enabled and we have no puppet proxy set and the upload came from puppet,
@@ -29,6 +29,7 @@ module ForemanPuppet
29
29
  has_many :config_groups, through: :config_group_classes
30
30
 
31
31
  has_many :class_params, -> { distinct }, through: :environment_classes, source: :puppetclass_lookup_key
32
+ accepts_nested_attributes_for :environment_classes
32
33
  accepts_nested_attributes_for :class_params, reject_if: ->(a) { a[:key].blank? }, allow_destroy: true
33
34
 
34
35
  validates :name, uniqueness: true, presence: true, no_whitespace: true
@@ -72,6 +73,17 @@ module ForemanPuppet
72
73
  hash
73
74
  end
74
75
 
76
+ # For Audits to be correctly taxed for Puppetclass creation
77
+ # Puppetclass gets saved before the environment class and thus taxonomy ids are empty
78
+ # We collect the ids from unsaved environment_classes for the Audits correct taxation
79
+ def location_ids
80
+ environment_classes.select(&:new_record?).flat_map { |ec| ec.environment.location_ids }.concat(super).uniq
81
+ end
82
+
83
+ def organization_ids
84
+ environment_classes.select(&:new_record?).flat_map { |ec| ec.environment.organization_ids }.concat(super).uniq
85
+ end
86
+
75
87
  # returns module name (excluding of the class name)
76
88
  # if class separator does not exists (the "::" chars), then returns the whole class name
77
89
  def module_name
@@ -106,7 +118,7 @@ module ForemanPuppet
106
118
  # We are going through two associations, so we are on our own to define modifiers
107
119
  def hostgroup_ids=(hg_ids)
108
120
  hg_ids = Array(hg_ids).reject(&:blank?)
109
- hg_to_facets_ids = Hash[HostgroupPuppetFacet.where(hostgroup_id: hg_ids).pluck(:hostgroup_id, :id)]
121
+ hg_to_facets_ids = HostgroupPuppetFacet.where(hostgroup_id: hg_ids).pluck(:hostgroup_id, :id).to_h
110
122
  missing_facet_ids = hg_ids.map(&:to_i) - hg_to_facets_ids.keys
111
123
  new_facet_ids = missing_facet_ids.map { |hg_id| HostgroupPuppetFacet.create(hostgroup_id: hg_id).id }
112
124
  self.hostgroup_puppet_facet_ids = hg_to_facets_ids.values + new_facet_ids
@@ -248,15 +248,11 @@ module ForemanPuppet
248
248
  end
249
249
 
250
250
  def add_classes_to_foreman(env_name, klasses)
251
- env = find_or_create_env env_name
252
- # look for Puppet class in all scopes to make sure we do not try to create a new record
253
- # with a name that already exists and hit the uniqueness constraint on name
254
- new_classes = klasses.map { |k| find_or_create_puppetclass(name: k[0]) }
251
+ env = find_or_create_env env_name
255
252
 
256
- new_classes.each do |new_class|
257
- EnvironmentClass.find_or_create_by! puppetclass_id: new_class.id, environment_id: env.id
258
- class_params = klasses[new_class.to_s]
259
- add_new_parameter(env, new_class, class_params) if class_params.any?
253
+ klasses.each do |klass_name, klass_params|
254
+ puppetclass = find_or_create_puppetclass_for_env(klass_name, env)
255
+ add_new_parameter(env, puppetclass, klass_params) if klass_params.any?
260
256
  end
261
257
  end
262
258
 
@@ -302,7 +298,7 @@ module ForemanPuppet
302
298
  changed_params['new'].map do |param_name, value|
303
299
  param = find_or_create_puppet_class_param klass, param_name, value
304
300
  EnvironmentClass.find_or_create_by! puppetclass_id: klass.id, environment_id: env.id,
305
- puppetclass_lookup_key_id: param.id
301
+ puppetclass_lookup_key_id: param.id
306
302
  end
307
303
  end
308
304
 
@@ -331,8 +327,8 @@ module ForemanPuppet
331
327
 
332
328
  def find_or_create_env(env)
333
329
  user_visible_environment(env) || Environment.create!(name: env,
334
- organizations: User.current.my_organizations,
335
- locations: User.current.my_locations)
330
+ organizations: User.current.my_organizations,
331
+ locations: User.current.my_locations)
336
332
  end
337
333
 
338
334
  def user_visible_environment(env)
@@ -343,11 +339,15 @@ module ForemanPuppet
343
339
  def find_or_create_puppet_class_param(klass, param_name, value)
344
340
  klass.class_params.where(key: param_name).first ||
345
341
  PuppetclassLookupKey.create!(key: param_name, default_value: value,
346
- key_type: Foreman::ImporterPuppetclass.suggest_key_type(value))
342
+ key_type: Foreman::ImporterPuppetclass.suggest_key_type(value))
347
343
  end
348
344
 
349
- def find_or_create_puppetclass(name:)
350
- puppetclass = Puppetclass.unscoped.find_or_create_by!(name: name)
345
+ def find_or_create_puppetclass_for_env(klass_name, env)
346
+ # look for Puppet class in all scopes to make sure we do not try to create a new record
347
+ # with a name that already exists and hit the uniqueness constraint on name
348
+ puppetclass = Puppetclass.find_or_initialize_by(name: klass_name)
349
+ puppetclass.environment_classes.find_or_initialize_by(environment_id: env.id)
350
+ puppetclass.save
351
351
  raise Foreman::Exception.new('Failed to create Puppetclass: %s', puppetclass.errors.full_messages.to_sentence) unless puppetclass.errors.empty?
352
352
  puppetclass
353
353
  end
@@ -0,0 +1,62 @@
1
+ <% title _("Changed environments") %>
2
+ <%= form_tag controller.send("obsolete_and_new_#{controller_name}_path") do %>
3
+ <h4><%= _("Select the changes you want to apply to Foreman") %></h4>
4
+ <h6>
5
+ <%= _("Toggle") %>:
6
+ <%= link_to_function(icon_text("check", _("New")),
7
+ "toggleCheckboxesBySelector('.env_select_boxes_new')",
8
+ :title => _("Check/Uncheck new")) %> |
9
+ <%= link_to_function(icon_text("check", _("Updated")),
10
+ "toggleCheckboxesBySelector('.env_select_boxes_updated')",
11
+ :title => _("Check/Uncheck updated")) %> |
12
+ <%= link_to_function(icon_text("check", _("Obsolete")),
13
+ "toggleCheckboxesBySelector('.env_select_boxes_obsolete')",
14
+ :title => _("Check/Uncheck obsolete")) %>
15
+ </h6>
16
+ <table class="<%= table_css_classes %>">
17
+ <thead>
18
+ <tr>
19
+ <th class="ca">
20
+ <%= link_to_function(icon_text("check"),
21
+ "toggleCheckboxesBySelector('.env_select_boxes')",
22
+ :title => _("Check/Uncheck all")) %>
23
+ </th>
24
+ <th><%= _("Environment") %></th>
25
+ <th><%= _("Operation") %></th>
26
+ <th><%= _("Puppet Modules") %></th>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+ <% for kind in ["new", "obsolete", "updated", "ignored"] %>
31
+ <% unless (envs = @changed[kind]).empty? %>
32
+ <% for env in envs.keys.sort %>
33
+ <tr>
34
+ <% unless kind == 'ignored' %>
35
+ <td>
36
+ <%= check_box_tag "changed[#{kind}][#{env}]", @changed[kind][env].to_json, false, :class => "env_select_boxes env_select_boxes_#{kind} env_select_boxes_env_#{env}" %>
37
+ </td>
38
+ <td>
39
+ <%= link_to_function("#{env}", "toggleCheckboxesBySelector('.env_select_boxes_env_#{env}')", :title => _("Check/Uncheck all %s changes") % env) %>
40
+ </td>
41
+ <% else %>
42
+ <td>&nbsp;</td>
43
+ <td><%= env %></td>
44
+ <% end %>
45
+ <td>
46
+ <%= {"new" => _("Add:"), "obsolete" => _("Remove:"), "updated" => _("Update:"), "ignored" => _("Ignored:")}[kind] %>
47
+ </td>
48
+ <td>
49
+ <% pcs = @changed[kind][env] %>
50
+ <%= class_update_text pcs, env %>
51
+ </td>
52
+ </tr>
53
+ <% end %>
54
+ <% end %>
55
+ <% end %>
56
+ </tbody>
57
+ </table>
58
+ <div>
59
+ <%= link_to _("Cancel"), controller.send("#{controller_name}_path"), :class => "btn btn-default" %>
60
+ <%= submit_tag _("Update"), :class => "btn btn-primary" %>
61
+ </div>
62
+ <% end %>
@@ -20,7 +20,7 @@
20
20
  <td>
21
21
  <%= action_buttons(
22
22
  link_to(_('Classes'), puppetclasses_path(search: "environment = #{environment}")),
23
- import_proxy_links(hash_for_import_environments_environments_path(env: environment)),
23
+ import_proxy_links(hash_for_import_environments_environments_path(env: environment).merge(engine: foreman_puppet)),
24
24
  display_delete_if_authorized(hash_for_environment_path(environment).merge(engine: foreman_puppet, auth_object: environment, authorizer: authorizer),
25
25
  data: { confirm: "Delete #{environment.name}?" })
26
26
  ) %>
@@ -11,6 +11,6 @@
11
11
  <%= new_link(_('Create Puppet Environment'), { engine: foreman_puppet }, { class: "btn-lg" }) %>
12
12
  </div>
13
13
  <div class="blank-slate-pf-secondary-action">
14
- <%= import_proxy_select(hash_for_import_environments_environments_path) %>
14
+ <%= import_proxy_select(hash_for_import_environments_environments_path.merge(engine: foreman_puppet)) %>
15
15
  </div>
16
16
  </div>
@@ -1,4 +1,4 @@
1
- <% Puppetclass.classes2hash(puppetclasses).sort.in_groups(2,nil) do |group| %>
1
+ <% ForemanPuppet::Puppetclass.classes2hash(puppetclasses).sort.in_groups(2,nil) do |group| %>
2
2
  <div class="col-md-6 classes">
3
3
  <% group.each do |list| %>
4
4
  <% next if list.nil? %>
@@ -1,4 +1,4 @@
1
- <%= content_tag :li, id: "selected_puppet_class_#{klass.id}", class: [dom_class(klass, 'selected'), cycle('even', 'odd'), ('unavailable' unless klass.environments.include?(@environment))] do %>
1
+ <%= content_tag :li, id: "selected_puppetclass_#{klass.id}", class: [dom_class(klass, 'selected'), cycle('even', 'odd'), ('unavailable' unless klass.environments.include?(@environment))] do %>
2
2
  <%= link_to_remove_puppetclass(klass, obj) %>
3
3
  <%= hidden_field_tag "#{resource_type}[puppetclass_ids][]", klass.id %>
4
4
  <% end %>
@@ -1,6 +1,6 @@
1
1
  <% title _("Puppet Classes") %>
2
2
 
3
- <% title_actions import_proxy_select(hash_for_import_environments_puppetclasses_path),
3
+ <% title_actions import_proxy_select(hash_for_import_environments_puppetclasses_path.merge(engine: foreman_puppet)),
4
4
  documentation_button('4.2.2Classes') %>
5
5
 
6
6
  <table class="<%= table_css_classes 'table-fixed' %>">
@@ -7,7 +7,7 @@
7
7
  <span id="puppet_klasses_reload_url" data-url="<%= foreman_puppet.environment_selected_hostgroups_path %>"></span>
8
8
  <% end %>
9
9
  <% if @environment.present? || obj.environment.present? %>
10
- <% if accessible_resource_records(:config_group).exists? %>
10
+ <% if accessible_resource_records('ForemanPuppet::ConfigGroup').exists? %>
11
11
  <%= render 'foreman_puppet/config_groups/config_groups_selection', obj: obj, resource_type: resource_type %>
12
12
  <% end %>
13
13
 
@@ -3,6 +3,6 @@
3
3
  <%= form_for :environment, url: foreman_puppet.update_multiple_environment_hosts_path(host_ids: params[:host_ids]) do |f| %>
4
4
  <%= selectable_f f, :id, [[_('Select environment'), 'disabled'],
5
5
  [_('*Clear environment*'), '' ],
6
- [_('*Inherit from host group*'), 'inherit']] + Environment.all.map{|e| [e.name, e.id]}, {},
6
+ [_('*Inherit from host group*'), 'inherit']] + ForemanPuppet::Environment.all.map{|e| [e.name, e.id]}, {},
7
7
  label: _('Environment'), onchange: 'tfm.hosts.table.toggleMultipleOkButton(this)' %>
8
8
  <% end %>
@@ -14,13 +14,13 @@ class MigrateHostTypeInHostConfigGroups < ActiveRecord::Migration[6.0]
14
14
 
15
15
  def down
16
16
  host_config_group_ids = HostConfigGroup.where(host_type: 'ForemanPuppet::HostPuppetFacet').pluck(:host_id).uniq
17
- host_facet_ids = Hash[ForemanPuppet::HostPuppetFacet.where(id: host_config_group_ids).pluck(:id, :host_id)]
17
+ host_facet_ids = ForemanPuppet::HostPuppetFacet.where(id: host_config_group_ids).pluck(:id, :host_id).to_h
18
18
  host_config_group_ids.each do |host_puppet_facet_id|
19
19
  HostConfigGroup.where(host_type: 'ForemanPuppet::HostPuppetFacet', host_id: host_puppet_facet_id)
20
20
  .update_all(host_type: 'Host::Managed', host_id: host_facet_ids[host_puppet_facet_id])
21
21
  end
22
22
  hostgroup_config_group_ids = HostConfigGroup.where(host_type: 'ForemanPuppet::HostgroupPuppetFacet').pluck(:host_id).uniq
23
- hostgroup_facet_ids = Hash[ForemanPuppet::HostgroupPuppetFacet.where(id: hostgroup_config_group_ids).pluck(:id, :hostgroup_id)]
23
+ hostgroup_facet_ids = ForemanPuppet::HostgroupPuppetFacet.where(id: hostgroup_config_group_ids).pluck(:id, :hostgroup_id).to_h
24
24
  hostgroup_config_group_ids.each do |hostgroup_facet_id|
25
25
  HostConfigGroup.where(host_type: 'ForemanPuppet::HostgroupPuppetFacet', host_id: hostgroup_facet_id)
26
26
  .update_all(host_type: 'Hostgroup', host_id: hostgroup_facet_ids[hostgroup_facet_id])
@@ -1,9 +1,9 @@
1
1
  module ForemanPuppet
2
- FOREMAN_EXTRACTION_VERSION = '2.5'.freeze
2
+ FOREMAN_EXTRACTION_VERSION = '3.0'.freeze
3
3
 
4
4
  def self.extracted_from_core?
5
5
  ENV['PUPPET_EXTRACTED'] == '1' ||
6
- Gem::Dependency.new('', ">= #{FOREMAN_EXTRACTION_VERSION}").match?('', SETTINGS[:version])
6
+ Gem::Dependency.new('', ">= #{FOREMAN_EXTRACTION_VERSION}").match?('', SETTINGS[:version].notag)
7
7
  end
8
8
  end
9
9
 
@@ -19,17 +19,19 @@ module ForemanPuppet
19
19
  end
20
20
  end
21
21
 
22
- initializer 'foreman_ansible.configure_assets', group: :assets do
22
+ initializer 'foreman_puppet.configure_assets', group: :assets do
23
23
  SETTINGS[:foreman_puppet] = { assets: { precompile: ['foreman_puppet.scss'] } }
24
24
  end
25
25
 
26
- # Include concerns in this config.to_prepare block
27
- config.to_prepare do
26
+ initializer 'foreman_puppet.patch_parameters' do
28
27
  # Parameters should go ASAP as they need to be applied before they are included in core controller
29
28
  Foreman::Controller::Parameters::Host.include ForemanPuppet::Extensions::ParametersHost
30
29
  Foreman::Controller::Parameters::Hostgroup.include ForemanPuppet::Extensions::ParametersHostgroup
31
30
  Foreman::Controller::Parameters::TemplateCombination.include ForemanPuppet::Extensions::ParametersTemplateCombination
31
+ end
32
32
 
33
+ # Include concerns in this config.to_prepare block
34
+ config.to_prepare do
33
35
  # Facets extenstion is applied too early - before the Hostgroup is complete
34
36
  # We redefine thing, so we need to wait until complete definition of Hostgroup
35
37
  # thus separate patching instead of using facet patching
@@ -65,6 +67,8 @@ module ForemanPuppet
65
67
  end
66
68
  Foreman.input_types_registry.register(ForemanPuppet::InputType::PuppetParameterInput)
67
69
  ::ProxyStatus.status_registry.add(ForemanPuppet::ProxyStatus::Puppet)
70
+ rescue StandardError => e
71
+ Rails.logger.warn "ForemanPuppet: skipping engine hook (#{e})\n#{e.backtrace.join("\n")}"
68
72
  end
69
73
 
70
74
  rake_tasks do
@@ -169,13 +169,14 @@ Foreman::Plugin.register :foreman_puppet do
169
169
  configure_host do
170
170
  # extend_model ForemanPuppet::Extensions::Host
171
171
  api_view list: 'foreman_puppet/api/v2/host_puppet_facets/base',
172
- single: 'foreman_puppet/api/v2/host_puppet_facets/host_single'
173
- template_compatibility_properties :environment, :environment_id, :environment_name
172
+ single: 'foreman_puppet/api/v2/host_puppet_facets/host_single'
173
+ template_compatibility_properties :environment, :environment_id, :environment_name,
174
+ :puppetclasses, :all_puppetclasses
174
175
  set_dependent_action :destroy
175
176
  end
176
177
  configure_hostgroup(ForemanPuppet::HostgroupPuppetFacet) do
177
178
  api_view list: 'foreman_puppet/api/v2/hostgroup_puppet_facets/base',
178
- single: 'foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single'
179
+ single: 'foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single'
179
180
  template_compatibility_properties :environment, :environment_id, :environment_name
180
181
  set_dependent_action :destroy
181
182
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanPuppet
2
- VERSION = '0.0.2'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
data/locale/Makefile CHANGED
@@ -6,7 +6,7 @@
6
6
  # make tx-update - download and merge translations from Transifex
7
7
  # make clean - clean everything
8
8
  #
9
- DOMAIN = foreman_puppet_enc
9
+ DOMAIN = foreman_puppet
10
10
  VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
11
11
  POTFILE = $(DOMAIN).pot
12
12
  MOFILE = $(DOMAIN).mo
@@ -1,10 +1,10 @@
1
- # foreman_puppet_enc
1
+ # foreman_puppet
2
2
  #
3
- # This file is distributed under the same license as foreman_puppet_enc.
3
+ # This file is distributed under the same license as foreman_puppet.
4
4
  #
5
5
  msgid ""
6
6
  msgstr ""
7
- "Project-Id-Version: version 0.0.1\n"
7
+ "Project-Id-Version: foreman_puppet 0.0.2\n"
8
8
  "Report-Msgid-Bugs-To: \n"
9
9
  "PO-Revision-Date: 2014-08-20 08:54+0100\n"
10
10
  "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
@@ -48,6 +48,9 @@ msgstr ""
48
48
  msgid "A config group provides a one-step method of associating many Puppet classes to either a host or host group. Typically this would be used to add a particular application profile or stack in one step."
49
49
  msgstr ""
50
50
 
51
+ msgid "Action with sub plans"
52
+ msgstr ""
53
+
51
54
  msgid "Actions"
52
55
  msgstr ""
53
56
 
@@ -66,6 +69,9 @@ msgstr ""
66
69
  msgid "All environments - (not filtered)"
67
70
  msgstr ""
68
71
 
72
+ msgid "Allow assigning Puppet environmets and classes to the Foreman Hosts."
73
+ msgstr ""
74
+
69
75
  msgid "Available Classes"
70
76
  msgstr ""
71
77
 
@@ -285,12 +291,18 @@ msgstr ""
285
291
  msgid "Import"
286
292
  msgstr ""
287
293
 
294
+ msgid "Import Puppet classes"
295
+ msgstr ""
296
+
288
297
  msgid "Import classes from %s"
289
298
  msgstr ""
290
299
 
291
300
  msgid "Import environments from %s"
292
301
  msgstr ""
293
302
 
303
+ msgid "Import facts"
304
+ msgstr ""
305
+
294
306
  msgid "Import puppet classes from puppet proxy"
295
307
  msgstr ""
296
308
 
@@ -510,6 +522,9 @@ msgstr ""
510
522
  msgid "Puppetclass|Name"
511
523
  msgstr ""
512
524
 
525
+ msgid "Remote action:"
526
+ msgstr ""
527
+
513
528
  msgid "Remove"
514
529
  msgstr ""
515
530
 
@@ -576,9 +591,6 @@ msgstr ""
576
591
  msgid "Successfully updated environments and Puppet classes from the on-disk Puppet installation"
577
592
  msgstr ""
578
593
 
579
- msgid "TODO: Description of ForemanPuppetEnc."
580
- msgstr ""
581
-
582
594
  msgid "The %{proxy_type} proxy could not be set for host: %{host_names}."
583
595
  msgid_plural "The %{proxy_type} puppet ca proxy could not be set for hosts: %{host_names}"
584
596
  msgstr[0] ""