foreman_puppet 1.0.3 → 2.0.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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/foreman_puppet/extensions/api_hostgroups_controller.rb +14 -16
  3. data/app/controllers/concerns/foreman_puppet/{api/import_puppetclasses_common_controller.rb → extensions/api_smart_proxies_controller.rb} +9 -3
  4. data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +23 -1
  5. data/app/controllers/concerns/foreman_puppet/extensions/api_v2_hosts_controller.rb +15 -17
  6. data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +3 -1
  7. data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +0 -1
  8. data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +41 -32
  9. data/app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb +37 -34
  10. data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +0 -1
  11. data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +1 -1
  12. data/app/controllers/foreman_puppet/puppetclasses_controller.rb +1 -1
  13. data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
  14. data/app/helpers/foreman_puppet/hosts_and_hostgroups_helper.rb +0 -5
  15. data/app/helpers/foreman_puppet/hosts_helper.rb +6 -10
  16. data/app/models/concerns/foreman_puppet/extensions/host.rb +2 -16
  17. data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +2 -7
  18. data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +7 -12
  19. data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +5 -10
  20. data/app/models/foreman_puppet/host_puppet_facet.rb +1 -1
  21. data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +2 -0
  22. data/app/services/concerns/foreman_puppet/extensions/host_counter.rb +17 -0
  23. data/app/services/foreman_puppet/puppet_class_importer.rb +0 -6
  24. data/app/views/foreman_puppet/api/v2/host_puppet_facets/host_list.json.rabl +3 -0
  25. data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/base.json.rabl +2 -0
  26. data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_list.json.rabl +3 -0
  27. data/app/views/foreman_puppet/config_groups/index.html.erb +1 -1
  28. data/config/api_routes.rb +1 -9
  29. data/config/initializers/api_reroute.rb +73 -5
  30. data/db/migrate/20101121140000_add_environment_to_template_combinations.foreman_puppet.rb +1 -1
  31. data/db/migrate/20200803113803_migrate_environment_to_puppet_facet.foreman_puppet.rb +2 -0
  32. data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +36 -20
  33. data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +0 -8
  34. data/db/migrate/20210924103241_remove_katello_id_from_environments.foreman_puppet.rb +5 -0
  35. data/db/migrate/20211111125003_drop_puppetclasses_direct_references.foreman_puppet.rb +11 -0
  36. data/db/migrate/20211112130803_cleanup_environment_from_core_tables.foreman_puppet.rb +10 -0
  37. data/db/migrate_foreman/{20090722141107_create_environments.rb → 20090722141107_create_environments.foreman_puppet.rb} +3 -3
  38. data/db/migrate_foreman/20090802062223_create_puppetclasses.foreman_puppet.rb +29 -0
  39. data/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb +12 -0
  40. data/db/migrate_foreman/20110412103238_remove_unused_fields_from_puppet_classes.foreman_puppet.rb +9 -0
  41. data/db/migrate_foreman/20110712070522_create_host_class.foreman_puppet.rb +11 -0
  42. data/db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb +21 -0
  43. data/db/migrate_foreman/{20120905095532_create_environment_classes.rb → 20120905095532_create_environment_classes.foreman_puppet.rb} +2 -2
  44. data/db/migrate_foreman/20121018152459_create_hostgroup_classes.foreman_puppet.rb +11 -0
  45. data/db/migrate_foreman/{20140407161817_create_config_groups.rb → 20140407161817_create_config_groups.foreman_puppet.rb} +0 -0
  46. data/db/migrate_foreman/{20140407162007_create_config_group_classes.rb → 20140407162007_create_config_group_classes.foreman_puppet.rb} +0 -0
  47. data/db/migrate_foreman/{20140407162059_create_host_config_groups.rb → 20140407162059_create_host_config_groups.foreman_puppet.rb} +0 -0
  48. data/db/migrate_foreman/{20161205142618_delete_orphaned_smart_class_parameters.rb → 20161205142618_delete_orphaned_smart_class_parameters.foreman_puppet.rb} +1 -1
  49. data/db/migrate_foreman/{20170109115157_fix_lookup_key_auditable_type.rb → 20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb} +0 -0
  50. data/db/migrate_foreman/20180816134832_cast_lookup_key_values.foreman_puppet.rb +5 -0
  51. data/db/migrate_foreman/20180831115634_add_uniqueness_to_puppetclass_name.foreman_puppet.rb +24 -0
  52. data/db/migrate_foreman/{20181023112532_add_environment_puppetclass_id.rb → 20181023112532_add_environment_puppetclass_id.foreman_puppet.rb} +1 -1
  53. data/db/migrate_foreman/{20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.rb → 20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.foreman_puppet.rb} +0 -0
  54. data/lib/foreman_puppet/engine.rb +6 -36
  55. data/lib/foreman_puppet/register.rb +49 -45
  56. data/lib/foreman_puppet/version.rb +1 -1
  57. data/lib/foreman_puppet.rb +1 -6
  58. data/locale/ca/LC_MESSAGES/foreman_puppet.mo +0 -0
  59. data/locale/ca/foreman_puppet.po +760 -0
  60. data/locale/cs_CZ/LC_MESSAGES/foreman_puppet.mo +0 -0
  61. data/locale/cs_CZ/foreman_puppet.edit.po +1085 -0
  62. data/locale/cs_CZ/foreman_puppet.po +823 -0
  63. data/locale/cs_CZ/foreman_puppet.po.time_stamp +0 -0
  64. data/locale/de/LC_MESSAGES/foreman_puppet.mo +0 -0
  65. data/locale/de/foreman_puppet.po +844 -0
  66. data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
  67. data/locale/en/foreman_puppet.edit.po +317 -162
  68. data/locale/en/foreman_puppet.po +119 -8
  69. data/locale/en_GB/LC_MESSAGES/foreman_puppet.mo +0 -0
  70. data/locale/en_GB/foreman_puppet.po +820 -0
  71. data/locale/es/LC_MESSAGES/foreman_puppet.mo +0 -0
  72. data/locale/es/foreman_puppet.po +827 -0
  73. data/locale/foreman_puppet.pot +376 -205
  74. data/locale/fr/LC_MESSAGES/foreman_puppet.mo +0 -0
  75. data/locale/fr/foreman_puppet.po +835 -0
  76. data/locale/gemspec.rb +1 -1
  77. data/locale/gl/LC_MESSAGES/foreman_puppet.mo +0 -0
  78. data/locale/gl/foreman_puppet.po +818 -0
  79. data/locale/it/LC_MESSAGES/foreman_puppet.mo +0 -0
  80. data/locale/it/foreman_puppet.po +822 -0
  81. data/locale/ja/LC_MESSAGES/foreman_puppet.mo +0 -0
  82. data/locale/ja/foreman_puppet.po +830 -0
  83. data/locale/ko/LC_MESSAGES/foreman_puppet.mo +0 -0
  84. data/locale/ko/foreman_puppet.po +819 -0
  85. data/locale/nl_NL/LC_MESSAGES/foreman_puppet.mo +0 -0
  86. data/locale/nl_NL/foreman_puppet.po +823 -0
  87. data/locale/pl/LC_MESSAGES/foreman_puppet.mo +0 -0
  88. data/locale/pl/foreman_puppet.po +822 -0
  89. data/locale/pt_BR/LC_MESSAGES/foreman_puppet.mo +0 -0
  90. data/locale/pt_BR/foreman_puppet.po +826 -0
  91. data/locale/ru/LC_MESSAGES/foreman_puppet.mo +0 -0
  92. data/locale/ru/foreman_puppet.po +827 -0
  93. data/locale/sv_SE/LC_MESSAGES/foreman_puppet.mo +0 -0
  94. data/locale/sv_SE/foreman_puppet.po +822 -0
  95. data/locale/zh_CN/LC_MESSAGES/foreman_puppet.mo +0 -0
  96. data/locale/zh_CN/foreman_puppet.po +831 -0
  97. data/locale/zh_TW/LC_MESSAGES/foreman_puppet.mo +0 -0
  98. data/locale/zh_TW/foreman_puppet.po +821 -0
  99. data/package.json +8 -11
  100. data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +0 -231
  101. data/test/controllers/foreman_puppet/api/v2/smart_proxies_controller_test.rb +255 -0
  102. data/test/controllers/foreman_puppet/environments_controller_test.rb +2 -2
  103. data/test/controllers/foreman_puppet/hosts_controller_test.rb +0 -1
  104. data/test/factories/foreman_puppet_factories.rb +0 -2
  105. data/test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb +70 -31
  106. data/test/integration/foreman_puppet/dashboard_js_test.rb +31 -0
  107. data/test/integration/foreman_puppet/host_js_test.rb +0 -1
  108. data/test/integration/foreman_puppet/puppetclass_js_test.rb +1 -1
  109. data/test/models/foreman_puppet/host_puppet_facet_test.rb +7 -1
  110. data/test/models/foreman_puppet/host_test.rb +26 -0
  111. data/test/models/foreman_puppet/user_test.rb +1 -5
  112. data/test/services/foreman_puppet/host_counter_test.rb +17 -0
  113. data/test/unit/foreman_puppet/puppet_class_importer_test.rb +1 -1
  114. data/webpack/src/Components/Environments/Welcome.js +2 -2
  115. metadata +73 -18
  116. data/db/migrate_foreman/20180816134832_cast_lookup_key_values.rb +0 -35
@@ -1,34 +1,50 @@
1
1
  Foreman::Plugin.register :foreman_puppet do
2
- requires_foreman '>= 2.0.0'
2
+ requires_foreman '>= 3.0.0'
3
3
  # Add Global JS file for extending foreman-core components and routes
4
4
  register_global_js_file 'fills'
5
5
 
6
- apipie_documented_controllers(["#{ForemanPuppet::Engine.root}/app/controllers/foreman_puppet/api/v2/*.rb"])
7
-
8
- unless ForemanPuppet.extracted_from_core?
9
- # Remove core permissions
10
- cfgs = %i[view_config_groups create_config_groups edit_config_groups destroy_config_groups]
11
- plks = %i[view_external_parameters create_external_parameters edit_external_parameters
12
- destroy_external_parameters]
13
- pcls = %i[view_puppetclasses create_puppetclasses edit_puppetclasses destroy_puppetclasses import_puppetclasses]
14
- (cfgs | plks | pcls).each do |perm_name|
15
- p = Foreman::AccessControl.permission(perm_name)
16
- Foreman::AccessControl.remove_permission(p)
6
+ settings do
7
+ category(:facts, N_('Facts')) do
8
+ setting('default_puppet_environment',
9
+ type: :string,
10
+ description: N_('Foreman will default to this puppet environment if it cannot auto detect one'),
11
+ default: 'production',
12
+ full_name: N_('Default Puppet environment'),
13
+ collection: proc { ForemanPuppet::Environment.pluck(:name).map { |name| [name, name] }.to_h })
14
+ setting('enc_environment',
15
+ type: :boolean,
16
+ description: N_('Foreman will explicitly set the puppet environment in the ENC yaml output. '\
17
+ 'This will avoid conflicts between the environment in puppet.conf and the environment set in Foreman'),
18
+ default: true,
19
+ full_name: N_('ENC environment'))
20
+ setting('update_environment_from_facts',
21
+ type: :boolean,
22
+ description: N_("Foreman will update a host's environment from its facts"),
23
+ default: false,
24
+ full_name: N_('Update environment from facts'))
17
25
  end
18
26
 
19
- delete_menu_item(:top_menu, :puppetclasses)
20
- delete_menu_item(:top_menu, :config_groups)
21
- delete_menu_item(:top_menu, :puppetclass_lookup_keys)
22
- delete_menu_item(:top_menu, :environments)
27
+ category(:cfgmgmt, N_('Config Management')) do
28
+ setting('puppet_interval',
29
+ type: :integer,
30
+ description: N_('Duration in minutes after servers reporting via Puppet are classed as out of sync.'),
31
+ default: 35,
32
+ full_name: N_('Puppet interval'))
33
+ setting('puppet_out_of_sync_disabled',
34
+ type: :boolean,
35
+ description: N_('Disable host configuration status turning to out of sync for %s after report does not arrive within configured interval') % 'Puppet',
36
+ default: false,
37
+ full_name: N_('%s out of sync disabled') % 'Puppet')
38
+ end
23
39
  end
24
40
 
41
+ apipie_documented_controllers(["#{ForemanPuppet::Engine.root}/app/controllers/foreman_puppet/api/v2/*.rb"])
42
+
25
43
  # TODO: maybe this would not be necessary if we rething the form
26
44
  %i[create_hostgroups edit_hostgroups].each do |perm|
27
45
  p = Foreman::AccessControl.permission(perm)
28
- if ForemanPuppet.extracted_from_core?
29
- p.actions << 'hostgroups/environment_selected'
30
- p.actions << 'hostgroups/puppetclass_parameters'
31
- end
46
+ p.actions << 'hostgroups/environment_selected'
47
+ p.actions << 'hostgroups/puppetclass_parameters'
32
48
  p.actions << 'foreman_puppet/puppetclasses/parameters'
33
49
  end
34
50
  p = Foreman::AccessControl.permission(:edit_hostgroups)
@@ -37,15 +53,13 @@ Foreman::Plugin.register :foreman_puppet do
37
53
  end
38
54
  %i[create_hosts edit_hosts].each do |perm|
39
55
  p = Foreman::AccessControl.permission(perm)
40
- if ForemanPuppet.extracted_from_core?
41
- p.actions << 'hosts/hostgroup_or_environment_selected'
42
- p.actions << 'hosts/puppetclass_parameters'
43
- if perm == :edit_hosts
44
- p.actions << 'hosts/select_multiple_environment'
45
- p.actions << 'hosts/update_multiple_environment'
46
- p.actions << 'hosts/select_multiple_puppet_proxy'
47
- p.actions << 'hosts/update_multiple_puppet_proxy'
48
- end
56
+ p.actions << 'hosts/hostgroup_or_environment_selected'
57
+ p.actions << 'hosts/puppetclass_parameters'
58
+ if perm == :edit_hosts
59
+ p.actions << 'hosts/select_multiple_environment'
60
+ p.actions << 'hosts/update_multiple_environment'
61
+ p.actions << 'hosts/select_multiple_puppet_proxy'
62
+ p.actions << 'hosts/update_multiple_puppet_proxy'
49
63
  end
50
64
  p.actions << 'foreman_puppet/puppetclasses/parameters'
51
65
  end
@@ -168,13 +182,13 @@ Foreman::Plugin.register :foreman_puppet do
168
182
  register_facet ForemanPuppet::HostPuppetFacet, :puppet do
169
183
  configure_host do
170
184
  # extend_model ForemanPuppet::Extensions::Host
171
- api_view list: 'foreman_puppet/api/v2/host_puppet_facets/base',
185
+ api_view list: 'foreman_puppet/api/v2/host_puppet_facets/host_list',
172
186
  single: 'foreman_puppet/api/v2/host_puppet_facets/host_single'
173
187
  template_compatibility_properties :environment, :environment_id, :environment_name
174
188
  set_dependent_action :destroy
175
189
  end
176
190
  configure_hostgroup(ForemanPuppet::HostgroupPuppetFacet) do
177
- api_view list: 'foreman_puppet/api/v2/hostgroup_puppet_facets/base',
191
+ api_view list: 'foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_list',
178
192
  single: 'foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single'
179
193
  template_compatibility_properties :environment, :environment_id, :environment_name
180
194
  set_dependent_action :destroy
@@ -185,14 +199,6 @@ Foreman::Plugin.register :foreman_puppet do
185
199
  base_scope.preload(puppet: :environment)
186
200
  end
187
201
 
188
- unless ForemanPuppet.extracted_from_core?
189
- Rails.application.config.after_initialize do
190
- list = Pagelets::Manager.instance.instance_variable_get(:@pagelets)['hosts/_form'][:main_tabs]
191
- core_pagelet = list.detect { |pagelet| pagelet.opts[:id] == :puppet_klasses }
192
- list.delete(core_pagelet)
193
- end
194
- end
195
-
196
202
  register_graphql_query_field :environment, 'ForemanPuppet::Types::Environment', :record_field
197
203
  register_graphql_query_field :environments, 'ForemanPuppet::Types::Environment', :collection_field
198
204
  register_graphql_query_field :puppetclass, 'ForemanPuppet::Types::Puppetclass', :record_field
@@ -212,12 +218,10 @@ Foreman::Plugin.register :foreman_puppet do
212
218
  priority: 100,
213
219
  onlyif: (host_onlyif if resource_type == :host)
214
220
 
215
- if ForemanPuppet.extracted_from_core?
216
- context.add_pagelet :main_tab_fields,
217
- partial: 'hosts/foreman_puppet/form_main_tab_fields',
218
- resource_type: resource_type,
219
- priority: 100
220
- end
221
+ context.add_pagelet :main_tab_fields,
222
+ partial: 'hosts/foreman_puppet/form_main_tab_fields',
223
+ resource_type: resource_type,
224
+ priority: 100
221
225
  end
222
226
  end
223
227
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanPuppet
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
@@ -1,10 +1,5 @@
1
1
  module ForemanPuppet
2
- FOREMAN_EXTRACTION_VERSION = '3.0'.freeze
3
-
4
- def self.extracted_from_core?
5
- ENV['PUPPET_EXTRACTED'].to_s == '1' ||
6
- Gem::Dependency.new('', ">= #{FOREMAN_EXTRACTION_VERSION}").match?('', SETTINGS[:version].notag)
7
- end
2
+ FOREMAN_DROP_MIGRATIONS_VERSION = '3.1'.freeze
8
3
  end
9
4
 
10
5
  require 'foreman_puppet/engine'