foreman_puppet 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -8,8 +8,8 @@ msgid ""
8
8
  msgstr ""
9
9
  "Project-Id-Version: foreman_puppet 1.0.0\n"
10
10
  "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2021-02-02 04:11+0100\n"
12
- "PO-Revision-Date: 2021-02-02 04:11+0100\n"
11
+ "POT-Creation-Date: 2021-02-03 18:00+0100\n"
12
+ "PO-Revision-Date: 2021-02-03 18:00+0100\n"
13
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
15
  "Language: \n"
@@ -1071,6 +1071,22 @@ msgstr ""
1071
1071
  msgid "Loading parameters..."
1072
1072
  msgstr ""
1073
1073
 
1074
+ #: action_names.rb:2
1075
+ msgid "Action with sub plans"
1076
+ msgstr ""
1077
+
1078
+ #: action_names.rb:3
1079
+ msgid "Import facts"
1080
+ msgstr ""
1081
+
1082
+ #: action_names.rb:4
1083
+ msgid "Import Puppet classes"
1084
+ msgstr ""
1085
+
1086
+ #: action_names.rb:5
1087
+ msgid "Remote action:"
1088
+ msgstr ""
1089
+
1074
1090
  #: gemspec.rb:2
1075
- msgid "TODO: Description of ForemanPuppetEnc."
1091
+ msgid "Allow assigning Puppet environmets and classes to the Foreman Hosts."
1076
1092
  msgstr ""
@@ -335,7 +335,7 @@ module ForemanPuppet
335
335
  # and should result in a disk_tree of {"env1" => ["a", "b", "c"],"env2" => ["a", "b", "c"]}
336
336
  envs = HashWithIndifferentAccess.new(env1: %w[a b c], env2: %w[a b c])
337
337
  pcs = [HashWithIndifferentAccess.new('a' => { 'name' => 'a', 'module' => nil, 'params' => { 'key' => 'special' } })]
338
- classes = Hash[pcs.map { |k| [k.keys.first, Foreman::ImporterPuppetclass.new(k.values.first)] }]
338
+ classes = pcs.map { |k| [k.keys.first, Foreman::ImporterPuppetclass.new(k.values.first)] }.to_h
339
339
  Environment.expects(:puppetEnvs).returns(envs).at_least(0)
340
340
  ProxyAPI::Puppet.any_instance.stubs(:environments).returns(%w[env1 env2])
341
341
  ProxyAPI::Puppet.any_instance.stubs(:classes).returns(classes)
@@ -92,7 +92,7 @@ module ForemanPuppet
92
92
  assert_response :success
93
93
  response = ActiveSupport::JSON.decode(@response.body)
94
94
  puppet_class = response['data']['classes'].keys
95
- assert_equal host.puppetclasses.map(&:name), puppet_class
95
+ assert_equal host.puppet.puppetclasses.map(&:name), puppet_class
96
96
  end
97
97
  end
98
98
  end
@@ -0,0 +1,32 @@
1
+ require 'test_puppet_helper'
2
+
3
+ module ForemanPuppet
4
+ module Api
5
+ module V2
6
+ class ProvisioningTemplatesControllerTest < ActionController::TestCase
7
+ tests ::Api::V2::ProvisioningTemplatesController
8
+
9
+ let(:environment) { FactoryBot.create(:environment) }
10
+
11
+ test 'should create provisioning template with template_combinations' do
12
+ name = RFauxFactory.gen_alpha
13
+ valid_attrs = {
14
+ name: name, template: RFauxFactory.gen_alpha, template_kind_id: template_kinds(:ipxe).id,
15
+ template_combinations_attributes: [
16
+ { hostgroup_id: hostgroups(:common).id, environment_id: environment.id },
17
+ ]
18
+ }
19
+ post :create, params: { provisioning_template: valid_attrs }
20
+ assert_response :created
21
+ response = ActiveSupport::JSON.decode(@response.body)
22
+ assert response.key?('id')
23
+ assert response.key?('template_combinations')
24
+ template_combinations = response['template_combinations']
25
+ assert_equal 1, template_combinations.length
26
+ template_combination = TemplateCombination.find(template_combinations[0]['id'])
27
+ assert_equal response['id'], template_combination.provisioning_template_id
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -215,7 +215,7 @@ module ForemanPuppet
215
215
  # and should result in a disk_tree of {"env1" => ["a", "b", "c"],"env2" => ["a", "b", "c"]}
216
216
  envs = HashWithIndifferentAccess.new(env1: %w[a b c], env2: %w[a b c])
217
217
  pcs = [HashWithIndifferentAccess.new('a' => { 'name' => 'a', 'module' => '', 'params' => {} })]
218
- classes = Hash[pcs.map { |k| [k.keys.first, Foreman::ImporterPuppetclass.new(k.values.first)] }]
218
+ classes = pcs.map { |k| [k.keys.first, Foreman::ImporterPuppetclass.new(k.values.first)] }.to_h
219
219
  Environment.expects(:puppetEnvs).returns(envs).at_least(0)
220
220
  ProxyAPI::Puppet.any_instance.stubs(:environments).returns(%w[env1 env2])
221
221
  ProxyAPI::Puppet.any_instance.stubs(:classes).returns(classes)
@@ -105,11 +105,14 @@ FactoryBot.define do
105
105
  evaluator.parameter_count.times do
106
106
  evaluator.environments.each do |env|
107
107
  FactoryBot.create :puppetclass_lookup_key, override: false, puppetclass: pc, environment: env
108
+ # for Host#managed validation, once extracted_from_core? we can remove
109
+ env.reload
108
110
  end
109
111
  end
110
112
  else
111
113
  evaluator.environments.each do |env|
112
114
  FactoryBot.create :environment_class, puppetclass: pc, environment: env unless env.nil?
115
+ env.reload
113
116
  end
114
117
  end
115
118
  end
@@ -14,6 +14,7 @@ module ForemanPuppet
14
14
  visit puppetclasses_path
15
15
  click_link 'vim'
16
16
  assert page.has_no_link? 'Common'
17
+ find(:xpath, "//a[@title='Select All']").hover
17
18
  find(:xpath, "//a[@data-original-title='Select All']").click
18
19
  assert_submit_button(puppetclasses_path)
19
20
  assert page.has_link? 'vim'
@@ -24,6 +25,7 @@ module ForemanPuppet
24
25
  smart_class_parameter_long = FactoryBot.create(:puppetclass_lookup_key, puppetclass: puppetclass, variable: 'a' * 50)
25
26
  visit edit_puppetclass_path(puppetclass)
26
27
  click_link 'Smart Class Parameter'
28
+ page.find("#pill_#{smart_class_parameter_long.id}-#{smart_class_parameter_long.key}").hover
27
29
  assert_equal smart_class_parameter_long.key, page.find("#pill_#{smart_class_parameter_long.id}-#{smart_class_parameter_long.key}")['data-original-title']
28
30
  end
29
31
 
@@ -31,6 +33,7 @@ module ForemanPuppet
31
33
  smart_class_parameter_short = FactoryBot.create(:puppetclass_lookup_key, puppetclass: puppetclass, variable: 'a' * 40)
32
34
  visit edit_puppetclass_path(puppetclass)
33
35
  click_link 'Smart Class Parameter'
36
+ page.find("#pill_#{smart_class_parameter_short.id}-#{smart_class_parameter_short.key}").hover
34
37
  assert_empty page.find("#pill_#{smart_class_parameter_short.id}-#{smart_class_parameter_short.key}")['data-original-title']
35
38
  end
36
39
  end
@@ -1,13 +1,46 @@
1
1
  require 'test_puppet_helper'
2
2
 
3
3
  module ForemanPuppet
4
- class HostgroupPuppetFacetTest < ActiveSupport::TestCase
4
+ class HostPuppetFacetTest < ActiveSupport::TestCase
5
5
  let(:environment) { FactoryBot.create(:environment) }
6
6
  let(:diff_environment) { FactoryBot.create(:environment) }
7
7
  let(:puppetclass_both) { FactoryBot.create(:puppetclass, environments: [environment, diff_environment]) }
8
8
  let(:config_group) { FactoryBot.create(:config_group, :with_puppetclass, class_environments: [environment]) }
9
9
  let(:config_group_diff_env) { FactoryBot.create(:config_group, :with_puppetclass, class_environments: [diff_environment]) }
10
10
 
11
+ describe '.populate_fields_from_facts' do
12
+ test 'populate environment without any puppet info' do
13
+ h = FactoryBot.create(:host)
14
+ parser = stub(environment: environment)
15
+ HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
16
+ assert_equal environment, h.puppet.environment
17
+ end
18
+
19
+ test 'changes puppet environment when setting says to do so' do
20
+ Setting[:update_environment_from_facts] = true
21
+ h = FactoryBot.create(:host, :with_puppet_enc)
22
+ parser = stub(environment: environment)
23
+ HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
24
+ assert_equal environment, h.puppet.environment
25
+ end
26
+
27
+ test 'keep puppet environment when parser has empty environment' do
28
+ Setting[:update_environment_from_facts] = true
29
+ h = FactoryBot.create(:host, :with_puppet_enc)
30
+ parser = stub(environment: nil)
31
+ HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
32
+ assert_not_nil h.puppet.environment
33
+ end
34
+
35
+ test 'do not update puppet environment when setting says not to' do
36
+ Setting[:update_environment_from_facts] = false
37
+ h = FactoryBot.create(:host, :with_puppet_enc)
38
+ parser = stub(environment: environment)
39
+ HostPuppetFacet.populate_fields_from_facts(h, parser, 'puppet', FactoryBot.create(:puppet_smart_proxy))
40
+ assert_not_equal environment, h.puppet.environment
41
+ end
42
+ end
43
+
11
44
  describe '#classes_in_groups' do
12
45
  test 'classes_in_groups should return the puppetclasses of a config group only if it is in host environment' do
13
46
  host = FactoryBot.create(:host, :with_puppet_enc,
@@ -241,7 +241,7 @@ module ForemanPuppet
241
241
 
242
242
  host.puppet.environment = env_with_other_tax
243
243
  assert_not host.valid?
244
- assert_match(/is not assigned/, host.errors[:environment_id].first)
244
+ assert_match(/is not assigned/, host.errors['puppet.environment_id'].first)
245
245
  end
246
246
 
247
247
  test 'when saving a host, require puppet environment if puppet master is set' do
@@ -77,47 +77,47 @@ module ForemanPuppet
77
77
  test 'find_template finds a matching template with hg and env' do
78
78
  assert_equal @ct1.name,
79
79
  ProvisioningTemplate.find_template({ kind: @tk.name,
80
- operatingsystem_id: @os1.id,
81
- hostgroup_id: @hg1.id,
82
- environment_id: @ev1.id }).name
80
+ operatingsystem_id: @os1.id,
81
+ hostgroup_id: @hg1.id,
82
+ environment_id: @ev1.id }).name
83
83
  end
84
84
 
85
85
  test 'find_template finds a matching template with hg only' do
86
86
  assert_equal @ct2.name,
87
87
  ProvisioningTemplate.find_template({ kind: @tk.name,
88
- operatingsystem_id: @os1.id,
89
- hostgroup_id: @hg1.id }).name
88
+ operatingsystem_id: @os1.id,
89
+ hostgroup_id: @hg1.id }).name
90
90
  end
91
91
 
92
92
  test 'find_template finds a matching template with hg and mismatched env' do
93
93
  assert_equal @ct2.name,
94
94
  ProvisioningTemplate.find_template({ kind: @tk.name,
95
- operatingsystem_id: @os1.id,
96
- hostgroup_id: @hg1.id,
97
- environment_id: @ev3.id }).name
95
+ operatingsystem_id: @os1.id,
96
+ hostgroup_id: @hg1.id,
97
+ environment_id: @ev3.id }).name
98
98
  end
99
99
 
100
100
  test 'find_template finds a matching template with env only' do
101
101
  assert_equal @ct3.name,
102
102
  ProvisioningTemplate.find_template({ kind: @tk.name,
103
- operatingsystem_id: @os1.id,
104
- environment_id: @ev1.id }).name
103
+ operatingsystem_id: @os1.id,
104
+ environment_id: @ev1.id }).name
105
105
  end
106
106
 
107
107
  test 'find_template finds a matching template with env and mismatched hg' do
108
108
  assert_equal @ct3.name,
109
109
  ProvisioningTemplate.find_template({ kind: @tk.name,
110
- operatingsystem_id: @os1.id,
111
- hostgroup_id: @hg3.id,
112
- environment_id: @ev1.id }).name
110
+ operatingsystem_id: @os1.id,
111
+ hostgroup_id: @hg3.id,
112
+ environment_id: @ev1.id }).name
113
113
  end
114
114
 
115
115
  test 'find_template finds the default template when hg and env do not match' do
116
116
  assert_equal @ctd.name,
117
117
  ProvisioningTemplate.find_template({ kind: @tk.name,
118
- operatingsystem_id: @os1.id,
119
- hostgroup_id: @hg3.id,
120
- environment_id: @ev3.id }).name
118
+ operatingsystem_id: @os1.id,
119
+ hostgroup_id: @hg3.id,
120
+ environment_id: @ev3.id }).name
121
121
  end
122
122
  end
123
123
  end
@@ -0,0 +1,21 @@
1
+ require 'test_puppet_helper'
2
+
3
+ module ForemanPuppet
4
+ class TestReport < ::Report
5
+ end
6
+
7
+ class ReportTest < ActiveSupport::TestCase
8
+ test 'Inherited children can search by environment' do
9
+ assert_nothing_raised do
10
+ TestReport.search_for('environment = blah')
11
+ end
12
+ end
13
+
14
+ # to include the environment search
15
+ test 'Inherited children can search' do
16
+ assert_nothing_raised do
17
+ TestReport.search_for('blah')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require 'test_puppet_helper'
2
+
3
+ module ForemanPuppet
4
+ class UserTest < ActiveSupport::TestCase
5
+ describe '#visible_environments' do
6
+ let(:environment) { FactoryBot.create(:environment) }
7
+ setup { environment }
8
+
9
+ # These will need refactor when the environment fixtures will be gone
10
+ test 'should show the list of environments visible as admin user' do
11
+ # Admin user sees all environments - including the ones without taxonomies
12
+ env_names = %w[production global_puppetmaster testing] + [environment.name]
13
+ assert_equal env_names.sort, ::User.current.visible_environments.sort
14
+ end
15
+
16
+ test 'should show the list of environments visible as inherited admin user' do
17
+ ::User.current = FactoryBot.create(:user, usergroups: [FactoryBot.create(:usergroup, admin: true)]).reload
18
+ env_names = %w[production global_puppetmaster testing] + [environment.name]
19
+ assert_same_elements env_names, ::User.current.visible_environments
20
+ end
21
+
22
+ test 'should show the list of environments visible as non-admin user' do
23
+ # Non-admin user only sees environments in a taxonomy at least
24
+ setup_user 'view', 'environments'
25
+ assert_equal [environment.name], ::User.current.visible_environments
26
+ end
27
+ end
28
+ end
29
+ end
@@ -37,9 +37,9 @@ module ForemanPuppet
37
37
 
38
38
  value = as_admin do
39
39
  LookupValue.create! lookup_key_id: puppetclass_lookup_key.id,
40
- match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
41
- value: 'test',
42
- omit: false
40
+ match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
41
+ value: 'test',
42
+ omit: false
43
43
  end
44
44
  enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
45
45
 
@@ -78,19 +78,17 @@ module ForemanPuppet
78
78
  host = FactoryBot.build_stubbed(:host, :with_puppet_enc, environment: environment, puppetclasses: [puppetclass])
79
79
  Classification::MatchesGenerator.any_instance.expects(:attr_to_value).with('comment').returns('override')
80
80
 
81
- assert_equal(
82
- {
83
- lkey.id => {
84
- lkey.key => {
85
- value: 'overridden value',
86
- element: 'comment',
87
- element_name: 'override',
88
- managed: false,
89
- },
81
+ expected = {
82
+ lkey.id => {
83
+ lkey.key => {
84
+ value: 'overridden value',
85
+ element: 'comment',
86
+ element_name: 'override',
87
+ managed: false,
90
88
  },
91
89
  },
92
- Classification::ValuesHashQuery.values_hash(host, LookupKey.where(id: [lkey])).raw
93
- )
90
+ }
91
+ assert_equal(expected, Classification::ValuesHashQuery.values_hash(host, LookupKey.where(id: [lkey])).raw)
94
92
 
95
93
  Classification::MatchesGenerator.any_instance.unstub(:attr_to_value)
96
94
  end
@@ -108,9 +106,9 @@ module ForemanPuppet
108
106
  puppetclass: puppetclass, path: "location\ncomment")
109
107
  as_admin do
110
108
  LookupValue.create! lookup_key_id: lkey.id,
111
- match: "location=#{taxonomies(:location1)}",
112
- value: 'test',
113
- omit: true
109
+ match: "location=#{taxonomies(:location1)}",
110
+ value: 'test',
111
+ omit: true
114
112
  end
115
113
 
116
114
  enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
@@ -124,9 +122,9 @@ module ForemanPuppet
124
122
  path: "location\ncomment")
125
123
  lvalue = as_admin do
126
124
  LookupValue.create! lookup_key_id: lkey.id,
127
- match: "location=#{taxonomies(:location1)}",
128
- value: 'test',
129
- omit: false
125
+ match: "location=#{taxonomies(:location1)}",
126
+ value: 'test',
127
+ omit: false
130
128
  end
131
129
 
132
130
  enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
@@ -142,22 +140,22 @@ module ForemanPuppet
142
140
 
143
141
  as_admin do
144
142
  LookupValue.create! lookup_key_id: key.id,
145
- match: "location=#{taxonomies(:location1)}",
146
- value: { example: { a: 'test' } },
147
- omit: true
143
+ match: "location=#{taxonomies(:location1)}",
144
+ value: { example: { a: 'test' } },
145
+ omit: true
148
146
  end
149
147
  as_admin do
150
148
  LookupValue.create! lookup_key_id: key.id,
151
- match: "organization=#{taxonomies(:organization1)}",
152
- value: { example: { b: 'test2' } },
153
- omit: true
149
+ match: "organization=#{taxonomies(:organization1)}",
150
+ value: { example: { b: 'test2' } },
151
+ omit: true
154
152
  end
155
153
 
156
154
  as_admin do
157
155
  LookupValue.create! lookup_key_id: key.id,
158
- match: "os=#{operatingsystems(:redhat)}",
159
- value: { example: { a: 'test3' } },
160
- omit: true
156
+ match: "os=#{operatingsystems(:redhat)}",
157
+ value: { example: { a: 'test3' } },
158
+ omit: true
161
159
  end
162
160
 
163
161
  enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
@@ -184,13 +182,13 @@ module ForemanPuppet
184
182
 
185
183
  as_admin do
186
184
  LookupValue.create! lookup_key_id: key.id,
187
- match: "hostgroup=#{parent_hostgroup}",
188
- value: ['parent'],
189
- omit: false
185
+ match: "hostgroup=#{parent_hostgroup}",
186
+ value: ['parent'],
187
+ omit: false
190
188
  LookupValue.create! lookup_key_id: key.id,
191
- match: "organization=#{taxonomies(:organization1)}",
192
- value: ['org'],
193
- omit: false
189
+ match: "organization=#{taxonomies(:organization1)}",
190
+ value: ['org'],
191
+ omit: false
194
192
  end
195
193
 
196
194
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -218,13 +216,13 @@ module ForemanPuppet
218
216
 
219
217
  as_admin do
220
218
  LookupValue.create! lookup_key_id: key.id,
221
- match: "organization=#{parent_org}",
222
- value: ['parent'],
223
- omit: false
219
+ match: "organization=#{parent_org}",
220
+ value: ['parent'],
221
+ omit: false
224
222
  LookupValue.create! lookup_key_id: key.id,
225
- match: "location=#{taxonomies(:location1)}",
226
- value: ['loc'],
227
- omit: false
223
+ match: "location=#{taxonomies(:location1)}",
224
+ value: ['loc'],
225
+ omit: false
228
226
  end
229
227
 
230
228
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -252,13 +250,13 @@ module ForemanPuppet
252
250
 
253
251
  as_admin do
254
252
  LookupValue.create! lookup_key_id: key.id,
255
- match: "location=#{parent_loc}",
256
- value: ['parent'],
257
- omit: false
253
+ match: "location=#{parent_loc}",
254
+ value: ['parent'],
255
+ omit: false
258
256
  LookupValue.create! lookup_key_id: key.id,
259
- match: "organization=#{taxonomies(:organization1)}",
260
- value: ['org'],
261
- omit: false
257
+ match: "organization=#{taxonomies(:organization1)}",
258
+ value: ['org'],
259
+ omit: false
262
260
  end
263
261
 
264
262
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -285,17 +283,17 @@ module ForemanPuppet
285
283
 
286
284
  as_admin do
287
285
  LookupValue.create! lookup_key_id: key.id,
288
- match: "hostgroup=#{parent_hostgroup}",
289
- value: ['parent'],
290
- omit: false
286
+ match: "hostgroup=#{parent_hostgroup}",
287
+ value: ['parent'],
288
+ omit: false
291
289
  LookupValue.create! lookup_key_id: key.id,
292
- match: "hostgroup=#{child_hostgroup}",
293
- value: ['child'],
294
- omit: false
290
+ match: "hostgroup=#{child_hostgroup}",
291
+ value: ['child'],
292
+ omit: false
295
293
  LookupValue.create! lookup_key_id: key.id,
296
- match: "organization=#{taxonomies(:organization1)}",
297
- value: ['org'],
298
- omit: false
294
+ match: "organization=#{taxonomies(:organization1)}",
295
+ value: ['org'],
296
+ omit: false
299
297
  end
300
298
 
301
299
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -323,17 +321,17 @@ module ForemanPuppet
323
321
 
324
322
  as_admin do
325
323
  LookupValue.create! lookup_key_id: key.id,
326
- match: "organization=#{parent_org}",
327
- value: ['parent'],
328
- omit: false
324
+ match: "organization=#{parent_org}",
325
+ value: ['parent'],
326
+ omit: false
329
327
  LookupValue.create! lookup_key_id: key.id,
330
- match: "organization=#{child_org}",
331
- value: ['child'],
332
- omit: false
328
+ match: "organization=#{child_org}",
329
+ value: ['child'],
330
+ omit: false
333
331
  LookupValue.create! lookup_key_id: key.id,
334
- match: "location=#{taxonomies(:location1)}",
335
- value: ['loc'],
336
- omit: false
332
+ match: "location=#{taxonomies(:location1)}",
333
+ value: ['loc'],
334
+ omit: false
337
335
  end
338
336
 
339
337
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -361,17 +359,17 @@ module ForemanPuppet
361
359
 
362
360
  as_admin do
363
361
  LookupValue.create! lookup_key_id: key.id,
364
- match: "location=#{parent_loc}",
365
- value: ['parent'],
366
- omit: false
362
+ match: "location=#{parent_loc}",
363
+ value: ['parent'],
364
+ omit: false
367
365
  LookupValue.create! lookup_key_id: key.id,
368
- match: "location=#{child_loc}",
369
- value: ['child'],
370
- omit: false
366
+ match: "location=#{child_loc}",
367
+ value: ['child'],
368
+ omit: false
371
369
  LookupValue.create! lookup_key_id: key.id,
372
- match: "organization=#{taxonomies(:organization1)}",
373
- value: ['org'],
374
- omit: false
370
+ match: "organization=#{taxonomies(:organization1)}",
371
+ value: ['org'],
372
+ omit: false
375
373
  end
376
374
 
377
375
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -398,17 +396,17 @@ module ForemanPuppet
398
396
 
399
397
  value2 = as_admin do
400
398
  LookupValue.create! lookup_key_id: key.id,
401
- match: "hostgroup=#{parent_hostgroup}",
402
- value: 'parent',
403
- omit: false
399
+ match: "hostgroup=#{parent_hostgroup}",
400
+ value: 'parent',
401
+ omit: false
404
402
  LookupValue.create! lookup_key_id: key.id,
405
- match: "hostgroup=#{child_hostgroup}",
406
- value: 'child',
407
- omit: false
403
+ match: "hostgroup=#{child_hostgroup}",
404
+ value: 'child',
405
+ omit: false
408
406
  LookupValue.create! lookup_key_id: key.id,
409
- match: "organization=#{taxonomies(:organization1)}",
410
- value: 'org',
411
- omit: false
407
+ match: "organization=#{taxonomies(:organization1)}",
408
+ value: 'org',
409
+ omit: false
412
410
  end
413
411
 
414
412
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -434,17 +432,17 @@ module ForemanPuppet
434
432
 
435
433
  value2 = as_admin do
436
434
  LookupValue.create! lookup_key_id: key.id,
437
- match: "organization=#{parent_org}",
438
- value: 'parent',
439
- omit: false
435
+ match: "organization=#{parent_org}",
436
+ value: 'parent',
437
+ omit: false
440
438
  LookupValue.create! lookup_key_id: key.id,
441
- match: "organization=#{child_org}",
442
- value: 'child',
443
- omit: false
439
+ match: "organization=#{child_org}",
440
+ value: 'child',
441
+ omit: false
444
442
  LookupValue.create! lookup_key_id: key.id,
445
- match: "location=#{taxonomies(:location1)}",
446
- value: 'loc',
447
- omit: false
443
+ match: "location=#{taxonomies(:location1)}",
444
+ value: 'loc',
445
+ omit: false
448
446
  end
449
447
 
450
448
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -470,17 +468,17 @@ module ForemanPuppet
470
468
 
471
469
  value2 = as_admin do
472
470
  LookupValue.create! lookup_key_id: key.id,
473
- match: "location=#{parent_loc}",
474
- value: 'parent',
475
- omit: false
471
+ match: "location=#{parent_loc}",
472
+ value: 'parent',
473
+ omit: false
476
474
  LookupValue.create! lookup_key_id: key.id,
477
- match: "location=#{child_loc}",
478
- value: 'child',
479
- omit: false
475
+ match: "location=#{child_loc}",
476
+ value: 'child',
477
+ omit: false
480
478
  LookupValue.create! lookup_key_id: key.id,
481
- match: "organization=#{taxonomies(:organization1)}",
482
- value: 'org',
483
- omit: false
479
+ match: "organization=#{taxonomies(:organization1)}",
480
+ value: 'org',
481
+ omit: false
484
482
  end
485
483
 
486
484
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -506,17 +504,17 @@ module ForemanPuppet
506
504
 
507
505
  value2 = as_admin do
508
506
  LookupValue.create! lookup_key_id: key.id,
509
- match: "hostgroup=#{parent_hostgroup}",
510
- value: 'parent',
511
- omit: false
507
+ match: "hostgroup=#{parent_hostgroup}",
508
+ value: 'parent',
509
+ omit: false
512
510
  LookupValue.create! lookup_key_id: key.id,
513
- match: "location=#{taxonomies(:location1)}",
514
- value: 'loc',
515
- omit: true
511
+ match: "location=#{taxonomies(:location1)}",
512
+ value: 'loc',
513
+ omit: true
516
514
  LookupValue.create! lookup_key_id: key.id,
517
- match: "hostgroup=#{child_hostgroup}",
518
- value: 'child',
519
- omit: false
515
+ match: "hostgroup=#{child_hostgroup}",
516
+ value: 'child',
517
+ omit: false
520
518
  end
521
519
 
522
520
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -544,17 +542,17 @@ module ForemanPuppet
544
542
 
545
543
  value2 = as_admin do
546
544
  LookupValue.create! lookup_key_id: key.id,
547
- match: "organization=#{parent_org}",
548
- value: 'parent',
549
- omit: false
545
+ match: "organization=#{parent_org}",
546
+ value: 'parent',
547
+ omit: false
550
548
  LookupValue.create! lookup_key_id: key.id,
551
- match: "location=#{taxonomies(:location1)}",
552
- value: 'loc',
553
- omit: true
549
+ match: "location=#{taxonomies(:location1)}",
550
+ value: 'loc',
551
+ omit: true
554
552
  LookupValue.create! lookup_key_id: key.id,
555
- match: "organization=#{child_org}",
556
- value: 'child',
557
- omit: false
553
+ match: "organization=#{child_org}",
554
+ value: 'child',
555
+ omit: false
558
556
  end
559
557
 
560
558
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -582,17 +580,17 @@ module ForemanPuppet
582
580
 
583
581
  value2 = as_admin do
584
582
  LookupValue.create! lookup_key_id: key.id,
585
- match: "location=#{parent_loc}",
586
- value: 'parent',
587
- omit: false
583
+ match: "location=#{parent_loc}",
584
+ value: 'parent',
585
+ omit: false
588
586
  LookupValue.create! lookup_key_id: key.id,
589
- match: "organization=#{taxonomies(:organization1)}",
590
- value: 'org',
591
- omit: true
587
+ match: "organization=#{taxonomies(:organization1)}",
588
+ value: 'org',
589
+ omit: true
592
590
  LookupValue.create! lookup_key_id: key.id,
593
- match: "location=#{child_loc}",
594
- value: 'child',
595
- omit: false
591
+ match: "location=#{child_loc}",
592
+ value: 'child',
593
+ omit: false
596
594
  end
597
595
 
598
596
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -608,13 +606,13 @@ module ForemanPuppet
608
606
 
609
607
  value2 = as_admin do
610
608
  LookupValue.create! lookup_key_id: key.id,
611
- match: "location=#{taxonomies(:location1)}",
612
- value: 'test_incorrect',
613
- omit: false
609
+ match: "location=#{taxonomies(:location1)}",
610
+ value: 'test_incorrect',
611
+ omit: false
614
612
  LookupValue.create! lookup_key_id: key.id,
615
- match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
616
- value: 'test_correct',
617
- omit: false
613
+ match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
614
+ value: 'test_correct',
615
+ omit: false
618
616
  end
619
617
  enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
620
618
  key.reload
@@ -630,15 +628,15 @@ module ForemanPuppet
630
628
 
631
629
  value = as_admin do
632
630
  LookupValue.create! lookup_key_id: key.id,
633
- match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
634
- value: 'test_correct',
635
- omit: false
631
+ match: "organization=#{taxonomies(:organization1)},location=#{taxonomies(:location1)}",
632
+ value: 'test_correct',
633
+ omit: false
636
634
  end
637
635
  as_admin do
638
636
  LookupValue.create! lookup_key_id: key.id,
639
- match: "organization=#{taxonomies(:organization1)}",
640
- value: 'test_incorrect',
641
- omit: false
637
+ match: "organization=#{taxonomies(:organization1)}",
638
+ value: 'test_incorrect',
639
+ omit: false
642
640
  end
643
641
  enc = HostInfoProviders::PuppetInfo.new(@host).puppetclass_parameters
644
642
 
@@ -662,22 +660,22 @@ module ForemanPuppet
662
660
 
663
661
  as_admin do
664
662
  LookupValue.create! lookup_key_id: key.id,
665
- match: "hostgroup=#{parent_hostgroup},organization=#{taxonomies(:organization1)}",
666
- value: 'parent',
667
- omit: false
663
+ match: "hostgroup=#{parent_hostgroup},organization=#{taxonomies(:organization1)}",
664
+ value: 'parent',
665
+ omit: false
668
666
  end
669
667
  value2 = as_admin do
670
668
  LookupValue.create! lookup_key_id: key.id,
671
- match: "hostgroup=#{child_hostgroup},organization=#{taxonomies(:organization1)}",
672
- value: 'child',
673
- omit: false
669
+ match: "hostgroup=#{child_hostgroup},organization=#{taxonomies(:organization1)}",
670
+ value: 'child',
671
+ omit: false
674
672
  end
675
673
 
676
674
  as_admin do
677
675
  LookupValue.create! lookup_key_id: key.id,
678
- match: "location=#{taxonomies(:location1)}",
679
- value: 'loc',
680
- omit: false
676
+ match: "location=#{taxonomies(:location1)}",
677
+ value: 'loc',
678
+ omit: false
681
679
  end
682
680
 
683
681
  enc = HostInfoProviders::PuppetInfo.new(host).puppetclass_parameters
@@ -694,21 +692,21 @@ module ForemanPuppet
694
692
 
695
693
  as_admin do
696
694
  LookupValue.create! lookup_key_id: key.id,
697
- match: "location=#{taxonomies(:location1)}",
698
- value: '<%= [2,3] %>',
699
- omit: false
695
+ match: "location=#{taxonomies(:location1)}",
696
+ value: '<%= [2,3] %>',
697
+ omit: false
700
698
  end
701
699
  as_admin do
702
700
  LookupValue.create! lookup_key_id: key.id,
703
- match: "organization=#{taxonomies(:organization1)}",
704
- value: '<%= [3,4] %>',
705
- omit: false
701
+ match: "organization=#{taxonomies(:organization1)}",
702
+ value: '<%= [3,4] %>',
703
+ omit: false
706
704
  end
707
705
  as_admin do
708
706
  LookupValue.create! lookup_key_id: key.id,
709
- match: "os=#{operatingsystems(:redhat)}",
710
- value: '<%= [4,5] %>',
711
- omit: false
707
+ match: "os=#{operatingsystems(:redhat)}",
708
+ value: '<%= [4,5] %>',
709
+ omit: false
712
710
  end
713
711
 
714
712
  key.reload
@@ -764,9 +762,9 @@ module ForemanPuppet
764
762
 
765
763
  as_admin do
766
764
  LookupValue.create! lookup_key_id: key.id,
767
- match: "location=#{taxonomies(:location1)}",
768
- value: '<%= "c" %>',
769
- omit: false
765
+ match: "location=#{taxonomies(:location1)}",
766
+ value: '<%= "c" %>',
767
+ omit: false
770
768
  end
771
769
 
772
770
  key.reload