foreman_puppet 1.0.5 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_hostgroups_controller.rb +14 -16
- data/app/controllers/concerns/foreman_puppet/{api/import_puppetclasses_common_controller.rb → extensions/api_smart_proxies_controller.rb} +16 -5
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +23 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_v2_hosts_controller.rb +15 -17
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +0 -1
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb +2 -8
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +0 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +1 -1
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +1 -1
- data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/hosts_and_hostgroups_helper.rb +0 -5
- data/app/helpers/foreman_puppet/hosts_helper.rb +6 -10
- data/app/models/concerns/foreman_puppet/extensions/host.rb +2 -16
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +2 -7
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +7 -12
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +5 -10
- data/app/services/foreman_puppet/puppet_class_importer.rb +0 -6
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/host_list.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/base.json.rabl +2 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_list.json.rabl +3 -0
- data/app/views/foreman_puppet/config_groups/_config_group.html.erb +5 -1
- data/app/views/foreman_puppet/config_groups/index.html.erb +1 -1
- data/config/api_routes.rb +1 -9
- data/config/initializers/api_reroute.rb +73 -5
- data/db/migrate/20101121140000_add_environment_to_template_combinations.foreman_puppet.rb +1 -1
- data/db/migrate/20200803113803_migrate_environment_to_puppet_facet.foreman_puppet.rb +2 -0
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +0 -8
- data/db/migrate/20210924103241_remove_katello_id_from_environments.foreman_puppet.rb +5 -0
- data/db/migrate/20211111125003_drop_puppetclasses_direct_references.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/{20090722141107_create_environments.rb → 20090722141107_create_environments.foreman_puppet.rb} +3 -3
- data/db/migrate_foreman/20090802062223_create_puppetclasses.foreman_puppet.rb +29 -0
- data/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb +12 -0
- data/db/migrate_foreman/20110412103238_remove_unused_fields_from_puppet_classes.foreman_puppet.rb +9 -0
- data/db/migrate_foreman/20110712070522_create_host_class.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb +21 -0
- data/db/migrate_foreman/{20120905095532_create_environment_classes.rb → 20120905095532_create_environment_classes.foreman_puppet.rb} +2 -2
- data/db/migrate_foreman/20121018152459_create_hostgroup_classes.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/{20140407161817_create_config_groups.rb → 20140407161817_create_config_groups.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20140407162007_create_config_group_classes.rb → 20140407162007_create_config_group_classes.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20140407162059_create_host_config_groups.rb → 20140407162059_create_host_config_groups.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20161205142618_delete_orphaned_smart_class_parameters.rb → 20161205142618_delete_orphaned_smart_class_parameters.foreman_puppet.rb} +1 -1
- data/db/migrate_foreman/{20170109115157_fix_lookup_key_auditable_type.rb → 20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.foreman_puppet.rb +5 -0
- data/db/migrate_foreman/20180831115634_add_uniqueness_to_puppetclass_name.foreman_puppet.rb +24 -0
- data/db/migrate_foreman/{20181023112532_add_environment_puppetclass_id.rb → 20181023112532_add_environment_puppetclass_id.foreman_puppet.rb} +1 -1
- 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
- data/lib/foreman_puppet/engine.rb +4 -36
- data/lib/foreman_puppet/register.rb +49 -45
- data/lib/foreman_puppet/version.rb +1 -1
- data/lib/foreman_puppet.rb +1 -6
- data/locale/ca/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ca/foreman_puppet.po +760 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/cs_CZ/foreman_puppet.po +823 -0
- data/locale/de/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/de/foreman_puppet.po +844 -0
- data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en/foreman_puppet.po +119 -8
- data/locale/en_GB/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en_GB/foreman_puppet.po +820 -0
- data/locale/es/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/es/foreman_puppet.po +827 -0
- data/locale/foreman_puppet.pot +376 -205
- data/locale/fr/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/fr/foreman_puppet.po +835 -0
- data/locale/gemspec.rb +1 -1
- data/locale/gl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/gl/foreman_puppet.po +818 -0
- data/locale/it/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/it/foreman_puppet.po +822 -0
- data/locale/ja/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ja/foreman_puppet.po +830 -0
- data/locale/ko/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ko/foreman_puppet.po +819 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/nl_NL/foreman_puppet.po +823 -0
- data/locale/pl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pl/foreman_puppet.po +822 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pt_BR/foreman_puppet.po +826 -0
- data/locale/ru/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ru/foreman_puppet.po +827 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/sv_SE/foreman_puppet.po +822 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_CN/foreman_puppet.po +831 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_TW/foreman_puppet.po +821 -0
- data/package.json +8 -11
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +24 -249
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/api/v2/smart_proxies_controller_test.rb +255 -0
- data/test/controllers/foreman_puppet/environments_controller_test.rb +3 -3
- data/test/controllers/foreman_puppet/hosts_controller_test.rb +0 -1
- data/test/factories/foreman_puppet_factories.rb +0 -2
- data/test/graphql/queries/environment_query_test.rb +4 -4
- data/test/graphql/queries/puppetclass_query_test.rb +4 -4
- data/test/integration/foreman_puppet/dashboard_js_test.rb +30 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +1 -2
- data/test/integration/foreman_puppet/host_js_test.rb +17 -19
- data/test/integration/foreman_puppet/hostgroup_js_test.rb +1 -2
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +2 -3
- data/test/integration/foreman_puppet/smartclass_parameter_js_test.rb +1 -2
- data/test/integration_puppet_helper.rb +3 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +2 -2
- data/test/models/foreman_puppet/host_test.rb +48 -22
- data/test/models/foreman_puppet/provisioning_template_test.rb +3 -3
- data/test/models/foreman_puppet/puppetclass_test.rb +1 -1
- data/test/models/foreman_puppet/user_test.rb +1 -5
- data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +1 -1
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +3 -3
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +1 -1
- data/test/unit/foreman_puppet/template_rendering_test.rb +1 -1
- metadata +66 -15
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.rb +0 -35
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'integration_puppet_helper'
|
2
|
+
require 'integration/shared/host_finders'
|
3
|
+
require 'integration/shared/host_orchestration_stubs'
|
4
|
+
|
5
|
+
module ForemanPuppet
|
6
|
+
class DashboardJSTest < IntegrationTestWithJavascript
|
7
|
+
setup do
|
8
|
+
Dashboard::Manager.reset_user_to_default(users(:admin))
|
9
|
+
Setting[:outofsync_interval] = 35
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'with origin' do
|
13
|
+
setup do
|
14
|
+
Setting[:puppet_out_of_sync_disabled] = true
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'out of sync disabled' do
|
18
|
+
test 'has no out of sync link' do
|
19
|
+
visit dashboard_path
|
20
|
+
wait_for_ajax
|
21
|
+
within "li[data-name='Host Configuration Status for Puppet']" do
|
22
|
+
assert page.has_no_link?('Out of sync hosts')
|
23
|
+
assert page.has_no_link?('Good host reports in the last')
|
24
|
+
assert page.has_link?('Good host with reports')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'integration_test_helper'
|
1
|
+
require 'integration_puppet_helper'
|
3
2
|
require 'integration/shared/host_finders'
|
4
3
|
require 'integration/shared/host_orchestration_stubs'
|
5
4
|
|
@@ -214,7 +213,7 @@ module ForemanPuppet
|
|
214
213
|
puppetclass: host.puppet.puppetclasses.first, overrides: { host.lookup_value_matcher => 'hostOverride' })
|
215
214
|
visit edit_host_path(host)
|
216
215
|
switch_form_tab('Puppet ENC')
|
217
|
-
|
216
|
+
expect(puppetclass_params.find('textarea').value).must_equal('hostOverride')
|
218
217
|
assert puppetclass_params.find('textarea:enabled')
|
219
218
|
puppetclass_params.find("a[data-tag='remove']").click
|
220
219
|
assert puppetclass_params.find('textarea:disabled')
|
@@ -222,17 +221,17 @@ module ForemanPuppet
|
|
222
221
|
|
223
222
|
visit edit_host_path(host)
|
224
223
|
switch_form_tab('Puppet ENC')
|
225
|
-
|
226
|
-
|
224
|
+
expect(puppetclass_params.find('textarea').value).must_equal('default')
|
225
|
+
expect(puppetclass_params).must_have_selector('textarea:disabled')
|
227
226
|
puppetclass_params.find("a[data-tag='override']").click
|
228
|
-
|
227
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
229
228
|
puppetclass_params.find('textarea').set('userCustom')
|
230
229
|
click_on_submit
|
231
230
|
|
232
231
|
visit edit_host_path(host)
|
233
232
|
switch_form_tab('Puppet ENC')
|
234
|
-
|
235
|
-
|
233
|
+
expect(puppetclass_params.find('textarea').value).must_equal('userCustom')
|
234
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
236
235
|
end
|
237
236
|
|
238
237
|
test 'can override puppetclass lookup values' do
|
@@ -241,22 +240,22 @@ module ForemanPuppet
|
|
241
240
|
|
242
241
|
visit edit_host_path(host)
|
243
242
|
switch_form_tab('Puppet ENC')
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
243
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='remove']", visible: :visible)
|
244
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='override']", visible: :hidden)
|
245
|
+
expect(puppetclass_params.find('textarea').value).must_equal('hostOverride')
|
246
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
248
247
|
|
249
248
|
puppetclass_params.find("a[data-tag='remove']").click
|
250
|
-
|
251
|
-
|
249
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='remove']", visible: :hidden)
|
250
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='override']", visible: :visible)
|
252
251
|
assert_equal('default', puppetclass_params.find('textarea').value)
|
253
252
|
assert puppetclass_params.find('textarea:disabled')
|
254
253
|
|
255
254
|
puppetclass_params.find("a[data-tag='override']").click
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
255
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='remove']", visible: :visible)
|
256
|
+
expect(puppetclass_params).must_have_selector("a[data-tag='override']", visible: :hidden)
|
257
|
+
expect(puppetclass_params.find('textarea').value).must_equal('default')
|
258
|
+
expect(puppetclass_params).must_have_selector('textarea:enabled')
|
260
259
|
end
|
261
260
|
|
262
261
|
context 'with non-admin user' do
|
@@ -362,7 +361,6 @@ module ForemanPuppet
|
|
362
361
|
page.find('#puppet_klasses_parameters_table')
|
363
362
|
end
|
364
363
|
|
365
|
-
# TODO: unless ForemanPuppet.extracted_from_core?
|
366
364
|
def switch_form_tab_to_interfaces
|
367
365
|
switch_form_tab('Interfaces')
|
368
366
|
disable_interface_modal_animation
|
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'integration_test_helper'
|
1
|
+
require 'integration_puppet_helper'
|
3
2
|
|
4
3
|
module ForemanPuppet
|
5
4
|
class PuppetclassJsTest < IntegrationTestWithJavascript
|
@@ -11,7 +10,7 @@ module ForemanPuppet
|
|
11
10
|
let(:puppetclass) { FactoryBot.create(:puppetclass, environments: [environment]) }
|
12
11
|
|
13
12
|
test 'edit page' do
|
14
|
-
FactoryBot.create(:puppetclass, name: 'vim', environments: [environment])
|
13
|
+
FactoryBot.create(:puppetclass, name: 'vim', environments: [environment])
|
15
14
|
visit puppetclasses_path
|
16
15
|
click_link 'vim'
|
17
16
|
assert page.has_no_link? 'Common'
|
@@ -107,13 +107,13 @@ module ForemanPuppet
|
|
107
107
|
test 'should return empty array if host has no hostgroup' do
|
108
108
|
host = FactoryBot.create(:host, :with_puppet_enc)
|
109
109
|
assert_not host.hostgroup
|
110
|
-
|
110
|
+
assert_empty host.puppet.parent_config_groups
|
111
111
|
end
|
112
112
|
|
113
113
|
test 'should return empty array if hostgroup do not have puppet data' do
|
114
114
|
hostgroup = FactoryBot.create(:hostgroup)
|
115
115
|
host = FactoryBot.create(:host, :with_puppet_enc, hostgroup: hostgroup)
|
116
|
-
|
116
|
+
assert_empty host.puppet.parent_config_groups
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
@@ -4,13 +4,13 @@ module ForemanPuppet
|
|
4
4
|
class HostTest < ActiveSupport::TestCase
|
5
5
|
test 'should read the Puppetserver URL from its proxy settings' do
|
6
6
|
host = FactoryBot.build_stubbed(:host)
|
7
|
-
|
8
|
-
|
7
|
+
expect(host.puppet_server_uri).must_be_nil
|
8
|
+
expect(host.puppetmaster).must_be_empty
|
9
9
|
|
10
10
|
proxy = FactoryBot.create(:puppet_smart_proxy, url: 'https://smartproxy.example.com:8443')
|
11
11
|
host.puppet_proxy = proxy
|
12
|
-
|
13
|
-
|
12
|
+
expect(host.puppet_server_uri.to_s).must_equal 'https://smartproxy.example.com:8140'
|
13
|
+
expect(host.puppetmaster).must_equal 'smartproxy.example.com'
|
14
14
|
|
15
15
|
features = {
|
16
16
|
'puppet' => {
|
@@ -18,8 +18,8 @@ module ForemanPuppet
|
|
18
18
|
},
|
19
19
|
}
|
20
20
|
SmartProxyFeature.import_features(proxy, features)
|
21
|
-
|
22
|
-
|
21
|
+
expect(host.puppet_server_uri.to_s).must_equal 'https://puppet.example.com:8140'
|
22
|
+
expect(host.puppetmaster).must_equal 'puppet.example.com'
|
23
23
|
end
|
24
24
|
|
25
25
|
test 'should find smart proxy ids' do
|
@@ -141,12 +141,38 @@ module ForemanPuppet
|
|
141
141
|
host = FactoryBot.create(:host, :with_puppet_enc, :with_config_group, :with_puppetclass, :with_parameter,
|
142
142
|
hostgroup: hostgroup, environment: hostgroup.puppet.environment)
|
143
143
|
copy = host.clone
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
144
|
+
expect(copy.puppet.individual_puppetclasses.map(&:id)).must_equal(host.puppet.individual_puppetclasses.map(&:id))
|
145
|
+
expect(copy.puppet.classes_in_groups.map(&:id)).must_equal(host.puppet.classes_in_groups.map(&:id))
|
146
|
+
expect(copy.puppet.classes.map(&:id)).must_equal(host.puppet.classes.map(&:id))
|
147
|
+
expect(copy.puppet.available_puppetclasses.map(&:id)).must_equal(host.puppet.available_puppetclasses.map(&:id))
|
148
|
+
expect(copy.puppet.host_classes.map(&:puppetclass_id)).must_equal(host.puppet.host_classes.map(&:puppetclass_id))
|
149
|
+
expect(copy.puppet.host_config_groups.map(&:config_group_id)).must_equal(host.puppet.host_config_groups.map(&:config_group_id))
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#available_template_kinds' do
|
154
|
+
let(:template_kinds) { [stub(name: 'iPXE'), stub(name: 'finish')] }
|
155
|
+
|
156
|
+
test 'calls find_template with Puppet environment' do
|
157
|
+
host = FactoryBot.create(:host, :with_hostgroup, :with_puppet_enc)
|
158
|
+
host.expects(:template_kinds).returns(template_kinds)
|
159
|
+
template_kinds.each do |kind|
|
160
|
+
::ProvisioningTemplate.expects(:find_template)
|
161
|
+
.with(kind: kind.name, operatingsystem_id: host.operatingsystem.id, hostgroup_id: host.hostgroup.id, environment_id: host.puppet.environment.id)
|
162
|
+
.returns(stub(name: "default #{kind.name}"))
|
163
|
+
end
|
164
|
+
assert_equal template_kinds.map { |k| "default #{k.name}" }, host.available_template_kinds.map(&:name)
|
165
|
+
end
|
166
|
+
|
167
|
+
test 'calls find_template without Puppet environment' do
|
168
|
+
host = FactoryBot.create(:host, :with_hostgroup)
|
169
|
+
host.expects(:template_kinds).returns(template_kinds)
|
170
|
+
template_kinds.each do |kind|
|
171
|
+
::ProvisioningTemplate.expects(:find_template)
|
172
|
+
.with(kind: kind.name, operatingsystem_id: host.operatingsystem.id, hostgroup_id: host.hostgroup.id, environment_id: nil)
|
173
|
+
.returns(stub(name: "default #{kind.name}"))
|
174
|
+
end
|
175
|
+
assert_equal template_kinds.map { |k| "default #{k.name}" }, host.available_template_kinds.map(&:name)
|
150
176
|
end
|
151
177
|
end
|
152
178
|
|
@@ -206,20 +232,20 @@ module ForemanPuppet
|
|
206
232
|
nodeinfo['parameters']['special_info'] = 'secret' # smart variable on apache
|
207
233
|
|
208
234
|
info = host.info
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
235
|
+
expect(host.puppet.environment.name).must_equal(env.name)
|
236
|
+
expect(info.keys).must_include 'environment'
|
237
|
+
expect(info.keys).must_include 'parameters'
|
238
|
+
expect(info.keys).must_include 'classes'
|
213
239
|
# This worked in core, but it's beyond me how could have :shrug:
|
214
240
|
# assert_equal(classes_params, info['classes'])
|
215
241
|
# We are only importing classes in the method
|
216
|
-
|
242
|
+
expect(info['classes'].keys.sort).must_equal(classes_params.keys.sort)
|
217
243
|
parameters = info['parameters']
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
244
|
+
expect(parameters['puppetmaster']).must_equal 'puppet'
|
245
|
+
expect(parameters['root_pw']).must_equal 'xybxa6JUkz63w'
|
246
|
+
expect(parameters['foreman_interfaces'].first['ip']).must_equal '3.3.4.12'
|
247
|
+
expect(parameters.keys).must_include 'foreman_subnets'
|
248
|
+
expect(parameters.keys).must_include 'foreman_interfaces'
|
223
249
|
end
|
224
250
|
|
225
251
|
test 'should import from non-parameterized external nodes output' do
|
@@ -32,9 +32,9 @@ module ForemanPuppet
|
|
32
32
|
assert tmplt.save
|
33
33
|
end
|
34
34
|
assert_nil tmplt.template_kind
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
assert_empty tmplt.hostgroups
|
36
|
+
assert_empty tmplt.environments
|
37
|
+
assert_empty tmplt.template_combinations
|
38
38
|
end
|
39
39
|
|
40
40
|
test '#template_includes adds environment include' do
|
@@ -17,7 +17,7 @@ module ForemanPuppet
|
|
17
17
|
end
|
18
18
|
|
19
19
|
test 'looking for a nonexistent host returns no puppetclasses' do
|
20
|
-
|
20
|
+
assert_empty Puppetclass.search_for('host = imaginaryhost.nodomain.what')
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'Puppetclass singularize from custom inflection' do
|
@@ -5,11 +5,7 @@ module ForemanPuppet
|
|
5
5
|
describe '#visible_environments' do
|
6
6
|
let(:environment) { FactoryBot.create(:environment) }
|
7
7
|
let(:untaxed_env) { FactoryBot.create(:environment, organizations: [], locations: []) }
|
8
|
-
let(:env_names)
|
9
|
-
env_names = [environment.name, untaxed_env.name]
|
10
|
-
env_names += %w[production global_puppetmaster testing] unless ForemanPuppet.extracted_from_core?
|
11
|
-
env_names
|
12
|
-
end
|
8
|
+
let(:env_names) { [environment.name, untaxed_env.name] }
|
13
9
|
|
14
10
|
setup do
|
15
11
|
environment
|
@@ -98,7 +98,7 @@ module ForemanPuppet
|
|
98
98
|
puppetclass: puppetclass)
|
99
99
|
|
100
100
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
101
|
-
|
101
|
+
assert_nil enc[puppetclass.name][lkey.key]
|
102
102
|
end
|
103
103
|
|
104
104
|
test '#enc should not return class parameters when lookup_value should use puppet default' do
|
@@ -113,7 +113,7 @@ module ForemanPuppet
|
|
113
113
|
|
114
114
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
115
115
|
|
116
|
-
|
116
|
+
assert_nil enc[puppetclass.name][lkey.key]
|
117
117
|
end
|
118
118
|
|
119
119
|
test '#enc should return class parameters when default value and lookup_values should not use puppet default' do
|
@@ -160,7 +160,7 @@ module ForemanPuppet
|
|
160
160
|
|
161
161
|
enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
|
162
162
|
|
163
|
-
|
163
|
+
assert_nil enc[puppetclass.name][key.key]
|
164
164
|
end
|
165
165
|
|
166
166
|
test '#enc should return correct merged override to host when multiple overrides for inherited hostgroups exist' do
|
@@ -3,7 +3,7 @@ require 'test_puppet_helper'
|
|
3
3
|
module ForemanPuppet
|
4
4
|
class PuppetClassImporterTest < ActiveSupport::TestCase
|
5
5
|
def setup
|
6
|
-
FactoryBot.create(:environment, name: 'production')
|
6
|
+
FactoryBot.create(:environment, name: 'production')
|
7
7
|
ProxyAPI::Puppet.any_instance.stubs(:environments).returns(%w[foreman-testing foreman-testing-1])
|
8
8
|
ProxyAPI::Puppet.any_instance.stubs(:classes).returns(mocked_classes)
|
9
9
|
User.current = users(:admin)
|
@@ -3,7 +3,7 @@ require 'test_puppet_helper'
|
|
3
3
|
module ForemanPuppet
|
4
4
|
class TemplateRenderingTest < ActiveSupport::TestCase
|
5
5
|
let(:host) { FactoryBot.build_stubbed(:host, :with_puppet_enc) }
|
6
|
-
let(:template) {
|
6
|
+
let(:template) { stub(name: 'Test', template: 'Test') }
|
7
7
|
let(:source) { Foreman::Renderer::Source::Database.new(template) }
|
8
8
|
let(:scope) do
|
9
9
|
Class.new(Foreman::Renderer::Scope::Base) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
@@ -9,9 +9,9 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-12-29 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: Allow assigning Puppet
|
14
|
+
description: Allow assigning Puppet environments and classes to the Foreman Hosts.
|
15
15
|
email:
|
16
16
|
- foreman-dev@googlegroups.com
|
17
17
|
executables: []
|
@@ -22,10 +22,10 @@ files:
|
|
22
22
|
- README.md
|
23
23
|
- Rakefile
|
24
24
|
- app/assets/stylesheets/foreman_puppet.scss
|
25
|
-
- app/controllers/concerns/foreman_puppet/api/import_puppetclasses_common_controller.rb
|
26
25
|
- app/controllers/concerns/foreman_puppet/environments_import.rb
|
27
26
|
- app/controllers/concerns/foreman_puppet/extensions/api_base_controller.rb
|
28
27
|
- app/controllers/concerns/foreman_puppet/extensions/api_hostgroups_controller.rb
|
28
|
+
- app/controllers/concerns/foreman_puppet/extensions/api_smart_proxies_controller.rb
|
29
29
|
- app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb
|
30
30
|
- app/controllers/concerns/foreman_puppet/extensions/api_v2_hosts_controller.rb
|
31
31
|
- app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb
|
@@ -113,9 +113,11 @@ files:
|
|
113
113
|
- app/views/foreman_puppet/api/v2/environments/show.json.rabl
|
114
114
|
- app/views/foreman_puppet/api/v2/environments/update.json.rabl
|
115
115
|
- app/views/foreman_puppet/api/v2/host_puppet_facets/base.json.rabl
|
116
|
+
- app/views/foreman_puppet/api/v2/host_puppet_facets/host_list.json.rabl
|
116
117
|
- app/views/foreman_puppet/api/v2/host_puppet_facets/host_single.json.rabl
|
117
118
|
- app/views/foreman_puppet/api/v2/host_puppet_facets/show.json.rabl
|
118
119
|
- app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/base.json.rabl
|
120
|
+
- app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_list.json.rabl
|
119
121
|
- app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single.json.rabl
|
120
122
|
- app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/show.json.rabl
|
121
123
|
- app/views/foreman_puppet/api/v2/import_puppetclasses/index.json.rabl
|
@@ -183,17 +185,26 @@ files:
|
|
183
185
|
- db/migrate/20200803113803_migrate_environment_to_puppet_facet.foreman_puppet.rb
|
184
186
|
- db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb
|
185
187
|
- db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb
|
188
|
+
- db/migrate/20210924103241_remove_katello_id_from_environments.foreman_puppet.rb
|
189
|
+
- db/migrate/20211111125003_drop_puppetclasses_direct_references.foreman_puppet.rb
|
186
190
|
- db/migrate/20211112130803_cleanup_environment_from_core_tables.foreman_puppet.rb
|
187
|
-
- db/migrate_foreman/20090722141107_create_environments.rb
|
188
|
-
- db/migrate_foreman/
|
189
|
-
- db/migrate_foreman/
|
190
|
-
- db/migrate_foreman/
|
191
|
-
- db/migrate_foreman/
|
192
|
-
- db/migrate_foreman/
|
193
|
-
- db/migrate_foreman/
|
194
|
-
- db/migrate_foreman/
|
195
|
-
- db/migrate_foreman/
|
196
|
-
- db/migrate_foreman/
|
191
|
+
- db/migrate_foreman/20090722141107_create_environments.foreman_puppet.rb
|
192
|
+
- db/migrate_foreman/20090802062223_create_puppetclasses.foreman_puppet.rb
|
193
|
+
- db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb
|
194
|
+
- db/migrate_foreman/20110412103238_remove_unused_fields_from_puppet_classes.foreman_puppet.rb
|
195
|
+
- db/migrate_foreman/20110712070522_create_host_class.foreman_puppet.rb
|
196
|
+
- db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb
|
197
|
+
- db/migrate_foreman/20120905095532_create_environment_classes.foreman_puppet.rb
|
198
|
+
- db/migrate_foreman/20121018152459_create_hostgroup_classes.foreman_puppet.rb
|
199
|
+
- db/migrate_foreman/20140407161817_create_config_groups.foreman_puppet.rb
|
200
|
+
- db/migrate_foreman/20140407162007_create_config_group_classes.foreman_puppet.rb
|
201
|
+
- db/migrate_foreman/20140407162059_create_host_config_groups.foreman_puppet.rb
|
202
|
+
- db/migrate_foreman/20161205142618_delete_orphaned_smart_class_parameters.foreman_puppet.rb
|
203
|
+
- db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb
|
204
|
+
- db/migrate_foreman/20180816134832_cast_lookup_key_values.foreman_puppet.rb
|
205
|
+
- db/migrate_foreman/20180831115634_add_uniqueness_to_puppetclass_name.foreman_puppet.rb
|
206
|
+
- db/migrate_foreman/20181023112532_add_environment_puppetclass_id.foreman_puppet.rb
|
207
|
+
- db/migrate_foreman/20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.foreman_puppet.rb
|
197
208
|
- db/seeds.d/111_puppet_proxy_feature.rb
|
198
209
|
- lib/foreman_puppet.rb
|
199
210
|
- lib/foreman_puppet/engine.rb
|
@@ -202,16 +213,50 @@ files:
|
|
202
213
|
- lib/tasks/foreman_puppet_tasks.rake
|
203
214
|
- locale/Makefile
|
204
215
|
- locale/action_names.rb
|
216
|
+
- locale/ca/LC_MESSAGES/foreman_puppet.mo
|
217
|
+
- locale/ca/foreman_puppet.po
|
218
|
+
- locale/cs_CZ/LC_MESSAGES/foreman_puppet.mo
|
205
219
|
- locale/cs_CZ/foreman_puppet.edit.po
|
220
|
+
- locale/cs_CZ/foreman_puppet.po
|
206
221
|
- locale/cs_CZ/foreman_puppet.po.time_stamp
|
222
|
+
- locale/de/LC_MESSAGES/foreman_puppet.mo
|
223
|
+
- locale/de/foreman_puppet.po
|
207
224
|
- locale/en/LC_MESSAGES/foreman_puppet.mo
|
208
225
|
- locale/en/foreman_puppet.edit.po
|
209
226
|
- locale/en/foreman_puppet.po
|
210
227
|
- locale/en/foreman_puppet.po.time_stamp
|
211
228
|
- locale/en/foreman_puppet.pox
|
229
|
+
- locale/en_GB/LC_MESSAGES/foreman_puppet.mo
|
230
|
+
- locale/en_GB/foreman_puppet.po
|
231
|
+
- locale/es/LC_MESSAGES/foreman_puppet.mo
|
232
|
+
- locale/es/foreman_puppet.po
|
212
233
|
- locale/foreman_puppet.pot
|
234
|
+
- locale/fr/LC_MESSAGES/foreman_puppet.mo
|
235
|
+
- locale/fr/foreman_puppet.po
|
213
236
|
- locale/gemspec.rb
|
237
|
+
- locale/gl/LC_MESSAGES/foreman_puppet.mo
|
238
|
+
- locale/gl/foreman_puppet.po
|
239
|
+
- locale/it/LC_MESSAGES/foreman_puppet.mo
|
240
|
+
- locale/it/foreman_puppet.po
|
241
|
+
- locale/ja/LC_MESSAGES/foreman_puppet.mo
|
242
|
+
- locale/ja/foreman_puppet.po
|
243
|
+
- locale/ko/LC_MESSAGES/foreman_puppet.mo
|
244
|
+
- locale/ko/foreman_puppet.po
|
214
245
|
- locale/messages.mo
|
246
|
+
- locale/nl_NL/LC_MESSAGES/foreman_puppet.mo
|
247
|
+
- locale/nl_NL/foreman_puppet.po
|
248
|
+
- locale/pl/LC_MESSAGES/foreman_puppet.mo
|
249
|
+
- locale/pl/foreman_puppet.po
|
250
|
+
- locale/pt_BR/LC_MESSAGES/foreman_puppet.mo
|
251
|
+
- locale/pt_BR/foreman_puppet.po
|
252
|
+
- locale/ru/LC_MESSAGES/foreman_puppet.mo
|
253
|
+
- locale/ru/foreman_puppet.po
|
254
|
+
- locale/sv_SE/LC_MESSAGES/foreman_puppet.mo
|
255
|
+
- locale/sv_SE/foreman_puppet.po
|
256
|
+
- locale/zh_CN/LC_MESSAGES/foreman_puppet.mo
|
257
|
+
- locale/zh_CN/foreman_puppet.po
|
258
|
+
- locale/zh_TW/LC_MESSAGES/foreman_puppet.mo
|
259
|
+
- locale/zh_TW/foreman_puppet.po
|
215
260
|
- package.json
|
216
261
|
- test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb
|
217
262
|
- test/controllers/foreman_puppet/api/v2/environments_controller_test.rb
|
@@ -224,6 +269,7 @@ files:
|
|
224
269
|
- test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb
|
225
270
|
- test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb
|
226
271
|
- test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb
|
272
|
+
- test/controllers/foreman_puppet/api/v2/smart_proxies_controller_test.rb
|
227
273
|
- test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb
|
228
274
|
- test/controllers/foreman_puppet/config_groups_controller_test.rb
|
229
275
|
- test/controllers/foreman_puppet/environments_controller_test.rb
|
@@ -247,11 +293,13 @@ files:
|
|
247
293
|
- test/graphql/queries/puppetclasses_query_test.rb
|
248
294
|
- test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb
|
249
295
|
- test/helpers/foreman_puppet/puppetclasses_helper_test.rb
|
296
|
+
- test/integration/foreman_puppet/dashboard_js_test.rb
|
250
297
|
- test/integration/foreman_puppet/environment_js_test.rb
|
251
298
|
- test/integration/foreman_puppet/host_js_test.rb
|
252
299
|
- test/integration/foreman_puppet/hostgroup_js_test.rb
|
253
300
|
- test/integration/foreman_puppet/puppetclass_js_test.rb
|
254
301
|
- test/integration/foreman_puppet/smartclass_parameter_js_test.rb
|
302
|
+
- test/integration_puppet_helper.rb
|
255
303
|
- test/models/foreman_puppet/config_group_class_test.rb
|
256
304
|
- test/models/foreman_puppet/config_group_test.rb
|
257
305
|
- test/models/foreman_puppet/environment_test.rb
|
@@ -319,7 +367,7 @@ requirements: []
|
|
319
367
|
rubygems_version: 3.1.6
|
320
368
|
signing_key:
|
321
369
|
specification_version: 4
|
322
|
-
summary:
|
370
|
+
summary: Add Puppet features to Foreman
|
323
371
|
test_files:
|
324
372
|
- test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb
|
325
373
|
- test/services/foreman_puppet/host_info_providers/puppet_info_test.rb
|
@@ -329,6 +377,7 @@ test_files:
|
|
329
377
|
- test/integration/foreman_puppet/puppetclass_js_test.rb
|
330
378
|
- test/integration/foreman_puppet/hostgroup_js_test.rb
|
331
379
|
- test/integration/foreman_puppet/environment_js_test.rb
|
380
|
+
- test/integration/foreman_puppet/dashboard_js_test.rb
|
332
381
|
- test/integration/foreman_puppet/host_js_test.rb
|
333
382
|
- test/graphql/mutations/hosts/create_mutation_test.rb
|
334
383
|
- test/graphql/queries/puppetclasses_query_test.rb
|
@@ -339,6 +388,7 @@ test_files:
|
|
339
388
|
- test/graphql/queries/environment_query_test.rb
|
340
389
|
- test/graphql/queries/hostgroup_puppet_query_test.rb
|
341
390
|
- test/graphql/queries/environments_query_test.rb
|
391
|
+
- test/integration_puppet_helper.rb
|
342
392
|
- test/helpers/foreman_puppet/puppetclasses_helper_test.rb
|
343
393
|
- test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb
|
344
394
|
- test/models/foreman_puppet/config_group_class_test.rb
|
@@ -379,6 +429,7 @@ test_files:
|
|
379
429
|
- test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb
|
380
430
|
- test/controllers/foreman_puppet/api/v2/host_classes_controller_test.rb
|
381
431
|
- test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb
|
432
|
+
- test/controllers/foreman_puppet/api/v2/smart_proxies_controller_test.rb
|
382
433
|
- test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb
|
383
434
|
- test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb
|
384
435
|
- test/controllers/foreman_puppet/puppetclasses_controller_test.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class CastLookupKeyValues < ActiveRecord::Migration[5.1]
|
2
|
-
def up
|
3
|
-
# Different LookupKey types handle casting a bit differently
|
4
|
-
PuppetclassLookupKey.unscoped.preload(:lookup_values).where(override: true).where.not(key_type: 'string').find_each do |key|
|
5
|
-
cast_key_and_values(key)
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def cast_key_and_values(key)
|
12
|
-
fix_value(key, :default_value)
|
13
|
-
key.lookup_values.each do |lv|
|
14
|
-
fix_value(lv, :value)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def safemode_box
|
19
|
-
@safemode_box ||= Safemode::Box.new
|
20
|
-
end
|
21
|
-
|
22
|
-
def fix_value(obj, attribute)
|
23
|
-
return if obj.omit && !obj.try(:merge_default)
|
24
|
-
value = obj.send(attribute)
|
25
|
-
return unless value.is_a? String
|
26
|
-
return if value.contains_erb?
|
27
|
-
fixed = safemode_box.eval(value)
|
28
|
-
obj.update_column(attribute, fixed)
|
29
|
-
rescue StandardError => e
|
30
|
-
say "Failed to cast #{attribute} for #{obj.inspect}:"
|
31
|
-
say "Value: #{value}", subitem: true
|
32
|
-
say "Error: #{e.message}", subitem: true
|
33
|
-
say 'Perhaps it is invalid? Casting skipped, manual action may be needed.', subitem: true
|
34
|
-
end
|
35
|
-
end
|