foreman_default_hostgroup 6.0.0 → 7.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.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/db/migrate/20221103122801_fix_default_hostgroup_settings_category_to_dsl.rb +9 -0
- data/lib/default_hostgroup_base_host_patch.rb +15 -17
- data/lib/foreman_default_hostgroup/engine.rb +28 -15
- data/lib/foreman_default_hostgroup/version.rb +1 -1
- data/test/unit/default_hostgroup_test.rb +38 -56
- metadata +9 -9
- data/app/models/setting/default_hostgroup.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08730dfb1749cc946d09ae2617082c8b5b0d3d9adbe2d1d4596139b9f02324b7'
|
4
|
+
data.tar.gz: 721b72f3b18205aefca9b3197762512a45c5ad00168da3abde9a0409222ed8f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bffa62fa45943f54e3903c58f76b33c51b28baf7875528ee2606118510f658803857d8d92888857356181c6d827a6df4e6384cb4b57bc0d9f8f8dd9b2934de29
|
7
|
+
data.tar.gz: e7e0d7c88f204afa63e06ef66b0add324809f3520b2d014cbd78830ae355ca1039bf06c5da4d48a645237ee6cfc9f28f5daf9873e23c6b3add3e0de918d48be7
|
data/README.md
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class FixDefaultHostgroupSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
|
4
|
+
def up
|
5
|
+
# rubocop:disable Rails/SkipsModelValidations
|
6
|
+
Setting.where(category: 'Setting::DefaultHostgroup').update_all(category: 'Setting') if column_exists?(:settings, :category)
|
7
|
+
# rubocop:enable Rails/SkipsModelValidations
|
8
|
+
end
|
9
|
+
end
|
@@ -24,7 +24,7 @@ module DefaultHostgroupBaseHostPatch
|
|
24
24
|
# Check settings are created
|
25
25
|
return result unless settings_exist?
|
26
26
|
|
27
|
-
Rails.logger.debug
|
27
|
+
Rails.logger.debug 'DefaultHostgroupMatch: performing Hostgroup match'
|
28
28
|
|
29
29
|
return result unless host_new_or_forced?
|
30
30
|
return result unless host_has_no_hostgroup_or_forced?
|
@@ -34,10 +34,10 @@ module DefaultHostgroupBaseHostPatch
|
|
34
34
|
|
35
35
|
return result unless new_hostgroup
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
Rails.logger.info "DefaultHostgroupMatch: #{facts[
|
37
|
+
host.hostgroup = new_hostgroup
|
38
|
+
host.environment = new_hostgroup.environment if (Setting[:force_host_environment] == true) && (facts[:_type] == :puppet)
|
39
|
+
host.save(validate: false)
|
40
|
+
Rails.logger.info "DefaultHostgroupMatch: #{facts['hostname']} added to #{new_hostgroup}"
|
41
41
|
|
42
42
|
result
|
43
43
|
end
|
@@ -52,14 +52,14 @@ module DefaultHostgroupBaseHostPatch
|
|
52
52
|
hg = Hostgroup.find_by(title: group_name)
|
53
53
|
return hg if hg.present? && group_matches?(facts)
|
54
54
|
end
|
55
|
-
Rails.logger.info
|
55
|
+
Rails.logger.info 'No match ...'
|
56
56
|
false
|
57
57
|
end
|
58
58
|
|
59
59
|
def group_matches?(facts)
|
60
60
|
facts.each do |fact_name, fact_regex|
|
61
|
-
fact_regex.gsub!(%r{(\A/|/\z)},
|
62
|
-
host_fact_value =
|
61
|
+
fact_regex.gsub!(%r{(\A/|/\z)}, '')
|
62
|
+
host_fact_value = host.facts[fact_name]
|
63
63
|
Rails.logger.info "Fact = #{fact_name}"
|
64
64
|
Rails.logger.info "Regex = #{fact_regex}"
|
65
65
|
return true if Regexp.new(fact_regex).match?(host_fact_value)
|
@@ -69,7 +69,7 @@ module DefaultHostgroupBaseHostPatch
|
|
69
69
|
|
70
70
|
def settings_exist?
|
71
71
|
unless SETTINGS[:default_hostgroup] && SETTINGS[:default_hostgroup][:facts_map]
|
72
|
-
Rails.logger.warn
|
72
|
+
Rails.logger.warn 'DefaultHostgroupMatch: Could not load :default_hostgroup map from Settings.'
|
73
73
|
return false
|
74
74
|
end
|
75
75
|
true
|
@@ -78,9 +78,9 @@ module DefaultHostgroupBaseHostPatch
|
|
78
78
|
def host_new_or_forced?
|
79
79
|
if Setting[:force_hostgroup_match_only_new]
|
80
80
|
# hosts have already been saved during import_host, so test the creation age instead
|
81
|
-
new_host = ((Time.current -
|
82
|
-
unless new_host &&
|
83
|
-
Rails.logger.debug
|
81
|
+
new_host = ((Time.current - host.created_at) < 300)
|
82
|
+
unless new_host && host.hostgroup.nil? && host.reports.empty?
|
83
|
+
Rails.logger.debug 'DefaultHostgroupMatch: skipping, host exists'
|
84
84
|
return false
|
85
85
|
end
|
86
86
|
end
|
@@ -88,11 +88,9 @@ module DefaultHostgroupBaseHostPatch
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def host_has_no_hostgroup_or_forced?
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
return false
|
95
|
-
end
|
91
|
+
if !Setting[:force_hostgroup_match] && host.hostgroup.present?
|
92
|
+
Rails.logger.debug 'DefaultHostgroupMatch: skipping, host has hostgroup'
|
93
|
+
return false
|
96
94
|
end
|
97
95
|
true
|
98
96
|
end
|
@@ -1,32 +1,45 @@
|
|
1
|
-
require
|
1
|
+
require 'default_hostgroup_base_host_patch'
|
2
2
|
|
3
3
|
module ForemanDefaultHostgroup
|
4
4
|
class Engine < ::Rails::Engine
|
5
|
-
engine_name
|
5
|
+
engine_name 'foreman_default_hostgroup'
|
6
6
|
|
7
7
|
config.autoload_paths += Dir["#{config.root}/app/models"]
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
# Add any db migrations
|
10
|
+
initializer 'foreman_default_hostgroup.load_app_instance_data' do |app|
|
11
|
+
ForemanDefaultHostgroup::Engine.paths['db/migrate'].existent.each do |path|
|
12
|
+
app.config.paths['db/migrate'] << path
|
13
|
+
end
|
14
14
|
end
|
15
15
|
|
16
|
-
initializer
|
16
|
+
initializer 'foreman_default_hostgroup.register_plugin',
|
17
17
|
before: :finisher_hook do
|
18
18
|
Foreman::Plugin.register :foreman_default_hostgroup do
|
19
|
-
requires_foreman
|
19
|
+
requires_foreman '>= 3.0'
|
20
|
+
|
21
|
+
settings do
|
22
|
+
category(:default_hostgroup, N_('Default Hostgroup')) do
|
23
|
+
setting('force_hostgroup_match',
|
24
|
+
type: :boolean,
|
25
|
+
description: 'Apply hostgroup matching even if a host already has one.',
|
26
|
+
default: false)
|
27
|
+
setting('force_hostgroup_match_only_new',
|
28
|
+
type: :boolean,
|
29
|
+
description: 'Apply hostgroup matching only on new hosts',
|
30
|
+
default: true)
|
31
|
+
setting('force_host_environment',
|
32
|
+
type: :boolean,
|
33
|
+
description: "Apply hostgroup's environment to host even if a host already has a different one",
|
34
|
+
default: true)
|
35
|
+
end
|
36
|
+
end
|
20
37
|
end
|
21
38
|
end
|
22
39
|
|
23
40
|
config.to_prepare do
|
24
|
-
|
25
|
-
|
26
|
-
::HostFactImporter.prepend DefaultHostgroupBaseHostPatch::ManagedOverrides
|
27
|
-
rescue StandardError => e
|
28
|
-
Rails.logger.warn "ForemanDefaultHostgroup: skipping engine hook (#{e})"
|
29
|
-
end
|
41
|
+
::HostFactImporter.include DefaultHostgroupBaseHostPatch
|
42
|
+
::HostFactImporter.prepend DefaultHostgroupBaseHostPatch::ManagedOverrides
|
30
43
|
end
|
31
44
|
end
|
32
45
|
end
|
@@ -17,21 +17,18 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
17
17
|
# The settings.yml fixture in Core wipes out the Setting table,
|
18
18
|
# so we use FactoryBot to re-create it
|
19
19
|
FactoryBot.create(:setting,
|
20
|
-
name: 'force_hostgroup_match'
|
21
|
-
category: 'Setting::DefaultHostgroup')
|
20
|
+
name: 'force_hostgroup_match')
|
22
21
|
FactoryBot.create(:setting,
|
23
|
-
name: 'force_hostgroup_match_only_new'
|
24
|
-
category: 'Setting::DefaultHostgroup')
|
22
|
+
name: 'force_hostgroup_match_only_new')
|
25
23
|
FactoryBot.create(:setting,
|
26
|
-
name: 'force_host_environment'
|
27
|
-
category: 'Setting::DefaultHostgroup')
|
24
|
+
name: 'force_host_environment')
|
28
25
|
# Set the defaults
|
29
26
|
Setting[:force_hostgroup_match] = false
|
30
27
|
Setting[:force_hostgroup_match_only_new] = true
|
31
28
|
Setting[:force_host_environment] = true
|
32
29
|
|
33
30
|
# Mimic plugin config fron config file
|
34
|
-
FactoryBot.create(:hostgroup,
|
31
|
+
FactoryBot.create(:hostgroup, name: 'Test Default')
|
35
32
|
SETTINGS[:default_hostgroup] = {}
|
36
33
|
SETTINGS[:default_hostgroup][:facts_map] = {
|
37
34
|
'Test Default' => { 'hostname' => '.*' }
|
@@ -39,7 +36,7 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
39
36
|
end
|
40
37
|
|
41
38
|
def setup_host_and_facts
|
42
|
-
raw = JSON.parse(File.read(File.
|
39
|
+
raw = JSON.parse(File.read(File.join(__dir__, 'facts.json')))
|
43
40
|
@name = raw['name']
|
44
41
|
@host = Host.import_host(raw['name'], 'puppet')
|
45
42
|
@facts = raw['facts']
|
@@ -47,7 +44,7 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
47
44
|
|
48
45
|
context 'import_facts_with_match_hostgroup' do
|
49
46
|
test 'matched host is saved with new hostgroup' do
|
50
|
-
assert @host.import_facts(@facts)
|
47
|
+
assert HostFactImporter.new(@host).import_facts(@facts)
|
51
48
|
assert_equal Hostgroup.find_by(name: 'Test Default'), Host.find_by(name: @name).hostgroup
|
52
49
|
end
|
53
50
|
|
@@ -56,7 +53,7 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
56
53
|
@host.hostgroup = hostgroup
|
57
54
|
@host.save(validate: false)
|
58
55
|
|
59
|
-
assert @host.import_facts(@facts)
|
56
|
+
assert HostFactImporter.new(@host).import_facts(@facts)
|
60
57
|
assert_equal hostgroup, Host.find_by(name: @name).hostgroup
|
61
58
|
end
|
62
59
|
|
@@ -64,40 +61,25 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
64
61
|
@host.created_at = Time.current - 1000
|
65
62
|
@host.save(validate: false)
|
66
63
|
|
67
|
-
assert @host.import_facts(@facts)
|
64
|
+
assert HostFactImporter.new(@host).import_facts(@facts)
|
68
65
|
assert_not Host.find_by(name: @name).hostgroup
|
69
66
|
end
|
70
67
|
end
|
71
68
|
|
72
|
-
context 'force host environment setting' do
|
73
|
-
test 'environment is updated if enabled' do
|
74
|
-
h = FactoryBot.create(:host, :with_environment, created_at: Time.current)
|
75
|
-
h.import_facts(@facts)
|
76
|
-
assert_equal Hostgroup.find_by(name: 'Test Default').environment, h.environment
|
77
|
-
end
|
78
|
-
|
79
|
-
test 'environment not updated if disabled' do
|
80
|
-
Setting[:force_host_environment] = false
|
81
|
-
h = FactoryBot.create(:host, :with_environment, created_at: Time.current)
|
82
|
-
h.import_facts(@facts)
|
83
|
-
assert_not_equal Hostgroup.find_by(name: 'Test Default').environment, h.environment
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
69
|
context 'find_match' do
|
88
70
|
# takes a config map, returns a group or false
|
89
71
|
test 'match a single hostgroup' do
|
90
72
|
facts_map = SETTINGS[:default_hostgroup][:facts_map]
|
91
|
-
assert @host.import_facts(@facts, nil, true)
|
92
|
-
assert_equal Hostgroup.find_by(name: 'Test Default'), @host.find_match(facts_map)
|
73
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
74
|
+
assert_equal Hostgroup.find_by(name: 'Test Default'), HostFactImporter.new(@host).find_match(facts_map)
|
93
75
|
end
|
94
76
|
|
95
77
|
test 'returns false for no match' do
|
96
78
|
facts_map = SETTINGS[:default_hostgroup][:facts_map] = {
|
97
79
|
'Test Default' => { 'hostname' => 'nosuchhost' }
|
98
80
|
}
|
99
|
-
assert @host.import_facts(@facts, nil, true)
|
100
|
-
assert_not @host.find_match(facts_map)
|
81
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
82
|
+
assert_not HostFactImporter.new(@host).find_match(facts_map)
|
101
83
|
end
|
102
84
|
|
103
85
|
test 'matches first available hostgroup' do
|
@@ -105,8 +87,8 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
105
87
|
'Test Default' => { 'hostname' => '.*' },
|
106
88
|
'Some Other Group' => { 'hostname' => '/\.lan$/' }
|
107
89
|
}
|
108
|
-
assert @host.import_facts(@facts, nil, true)
|
109
|
-
assert_equal Hostgroup.find_by(name: 'Test Default'), @host.find_match(facts_map)
|
90
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
91
|
+
assert_equal Hostgroup.find_by(name: 'Test Default'), HostFactImporter.new(@host).find_match(facts_map)
|
110
92
|
end
|
111
93
|
|
112
94
|
test 'nonexistant groups are ignored' do
|
@@ -114,8 +96,8 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
114
96
|
'Some Other Group' => { 'hostname' => '.*' },
|
115
97
|
'Test Default' => { 'hostname' => '/\.lan$/' }
|
116
98
|
}
|
117
|
-
assert @host.import_facts(@facts, nil, true)
|
118
|
-
assert_equal Hostgroup.find_by(name: 'Test Default'), @host.find_match(facts_map)
|
99
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
100
|
+
assert_equal Hostgroup.find_by(name: 'Test Default'), HostFactImporter.new(@host).find_match(facts_map)
|
119
101
|
end
|
120
102
|
end
|
121
103
|
|
@@ -123,32 +105,32 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
123
105
|
# passing a hash of (group_name, regex) pairs
|
124
106
|
test 'full regex matches' do
|
125
107
|
regex = { 'hostname' => '^sinn1636.lan$' }
|
126
|
-
assert @host.import_facts(@facts, nil, true)
|
127
|
-
assert @host.group_matches?(regex)
|
108
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
109
|
+
assert HostFactImporter.new(@host).group_matches?(regex)
|
128
110
|
end
|
129
111
|
|
130
112
|
test 'partial regex matches' do
|
131
113
|
regex = { 'hostname' => '.lan$' }
|
132
|
-
assert @host.import_facts(@facts, nil, true)
|
133
|
-
assert @host.group_matches?(regex)
|
114
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
115
|
+
assert HostFactImporter.new(@host).group_matches?(regex)
|
134
116
|
end
|
135
117
|
|
136
118
|
test 'regex slashes are stripped' do
|
137
119
|
regex = { 'hostname' => '/\.lan$/' }
|
138
|
-
assert @host.import_facts(@facts, nil, true)
|
139
|
-
assert @host.group_matches?(regex)
|
120
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
121
|
+
assert HostFactImporter.new(@host).group_matches?(regex)
|
140
122
|
end
|
141
123
|
|
142
124
|
test 'invalid keys are ignored' do
|
143
125
|
regex = { 'nosuchfact' => '.*' }
|
144
|
-
assert @host.import_facts(@facts, nil, true)
|
145
|
-
assert_not @host.group_matches?(regex)
|
126
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
127
|
+
assert_not HostFactImporter.new(@host).group_matches?(regex)
|
146
128
|
end
|
147
129
|
|
148
130
|
test 'unmatched values are ignored' do
|
149
131
|
regex = { 'hostname' => 'nosuchname' }
|
150
|
-
assert @host.import_facts(@facts, nil, true)
|
151
|
-
assert_not @host.group_matches?(regex)
|
132
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
133
|
+
assert_not HostFactImporter.new(@host).group_matches?(regex)
|
152
134
|
end
|
153
135
|
|
154
136
|
test 'multiple entries with invalid keys / values match' do
|
@@ -157,67 +139,67 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
157
139
|
'osfamily' => 'nosuchos',
|
158
140
|
'hostname' => '.lan$'
|
159
141
|
}
|
160
|
-
assert @host.import_facts(@facts, nil, true)
|
161
|
-
assert @host.group_matches?(regex)
|
142
|
+
assert HostFactImporter.new(@host).import_facts(@facts, nil, true)
|
143
|
+
assert HostFactImporter.new(@host).group_matches?(regex)
|
162
144
|
end
|
163
145
|
end
|
164
146
|
|
165
147
|
context 'settings_exist?' do
|
166
148
|
test 'true when Settings exist' do
|
167
149
|
h = FactoryBot.create(:host)
|
168
|
-
assert h.settings_exist?
|
150
|
+
assert HostFactImporter.new(h).settings_exist?
|
169
151
|
end
|
170
152
|
|
171
153
|
test 'false when Settings are missing' do
|
172
154
|
SETTINGS[:default_hostgroup] = {}
|
173
155
|
h = FactoryBot.create(:host)
|
174
|
-
assert_not h.settings_exist?
|
156
|
+
assert_not HostFactImporter.new(h).settings_exist?
|
175
157
|
end
|
176
158
|
end
|
177
159
|
|
178
160
|
context 'host_new_or_forced?' do
|
179
161
|
test 'true when host is new' do
|
180
162
|
h = FactoryBot.create(:host, created_at: Time.current)
|
181
|
-
assert h.host_new_or_forced?
|
163
|
+
assert HostFactImporter.new(h).host_new_or_forced?
|
182
164
|
end
|
183
165
|
|
184
166
|
test 'false when host has existed for > 300s' do
|
185
167
|
h = FactoryBot.create(:host, created_at: Time.current - 1000)
|
186
|
-
assert_not h.host_new_or_forced?
|
168
|
+
assert_not HostFactImporter.new(h).host_new_or_forced?
|
187
169
|
end
|
188
170
|
|
189
171
|
test 'false when host has a hostgroup' do
|
190
172
|
h = FactoryBot.create(:host, :with_hostgroup, created_at: Time.current)
|
191
|
-
assert_not h.host_new_or_forced?
|
173
|
+
assert_not HostFactImporter.new(h).host_new_or_forced?
|
192
174
|
end
|
193
175
|
|
194
176
|
test 'false when host has reports' do
|
195
177
|
h = FactoryBot.create(:host, :with_reports, created_at: Time.current)
|
196
|
-
assert_not h.host_new_or_forced?
|
178
|
+
assert_not HostFactImporter.new(h).host_new_or_forced?
|
197
179
|
end
|
198
180
|
|
199
181
|
test 'true when setting is forced' do
|
200
182
|
Setting[:force_hostgroup_match_only_new] = false
|
201
183
|
h = FactoryBot.create(:host, :with_hostgroup, created_at: Time.current)
|
202
|
-
assert h.host_new_or_forced?
|
184
|
+
assert HostFactImporter.new(h).host_new_or_forced?
|
203
185
|
end
|
204
186
|
end
|
205
187
|
|
206
188
|
context 'host_has_no_hostgroup_or_forced?' do
|
207
189
|
test 'true if host has no hostgroup' do
|
208
190
|
h = FactoryBot.create(:host)
|
209
|
-
assert h.host_has_no_hostgroup_or_forced?
|
191
|
+
assert HostFactImporter.new(h).host_has_no_hostgroup_or_forced?
|
210
192
|
end
|
211
193
|
|
212
194
|
test 'false if host has hostgroup' do
|
213
195
|
h = FactoryBot.create(:host, :with_hostgroup)
|
214
|
-
assert_not h.host_has_no_hostgroup_or_forced?
|
196
|
+
assert_not HostFactImporter.new(h).host_has_no_hostgroup_or_forced?
|
215
197
|
end
|
216
198
|
|
217
199
|
test 'true if host has hostgroup and setting forced' do
|
218
200
|
Setting[:force_hostgroup_match] = true
|
219
201
|
h = FactoryBot.create(:host, :with_hostgroup)
|
220
|
-
assert h.host_has_no_hostgroup_or_forced?
|
202
|
+
assert HostFactImporter.new(h).host_has_no_hostgroup_or_forced?
|
221
203
|
end
|
222
204
|
end
|
223
205
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_default_hostgroup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sutcliffe
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-04-03 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Adds the option to specify a default hostgroup for new hosts created
|
14
13
|
from facts/reports
|
@@ -21,7 +20,7 @@ extra_rdoc_files:
|
|
21
20
|
files:
|
22
21
|
- LICENSE
|
23
22
|
- README.md
|
24
|
-
-
|
23
|
+
- db/migrate/20221103122801_fix_default_hostgroup_settings_category_to_dsl.rb
|
25
24
|
- default_hostgroup.yaml.example
|
26
25
|
- lib/default_hostgroup_base_host_patch.rb
|
27
26
|
- lib/foreman_default_hostgroup.rb
|
@@ -35,7 +34,6 @@ homepage: https://github.com/theforeman/foreman_default_hostgroup
|
|
35
34
|
licenses:
|
36
35
|
- GPL-3.0
|
37
36
|
metadata: {}
|
38
|
-
post_install_message:
|
39
37
|
rdoc_options: []
|
40
38
|
require_paths:
|
41
39
|
- lib
|
@@ -43,18 +41,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
43
41
|
requirements:
|
44
42
|
- - ">="
|
45
43
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
44
|
+
version: '2.7'
|
45
|
+
- - "<"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4'
|
47
48
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
49
|
requirements:
|
49
50
|
- - ">="
|
50
51
|
- !ruby/object:Gem::Version
|
51
52
|
version: '0'
|
52
53
|
requirements: []
|
53
|
-
rubygems_version: 3.
|
54
|
-
signing_key:
|
54
|
+
rubygems_version: 3.6.2
|
55
55
|
specification_version: 4
|
56
56
|
summary: Default Hostgroup Plugin for Foreman
|
57
57
|
test_files:
|
58
58
|
- test/test_plugin_helper.rb
|
59
|
-
- test/unit/facts.json
|
60
59
|
- test/unit/default_hostgroup_test.rb
|
60
|
+
- test/unit/facts.json
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# rubocop:disable Style/ClassAndModuleChildren
|
2
|
-
class Setting::DefaultHostgroup < ::Setting
|
3
|
-
# rubocop:enable Style/ClassAndModuleChildren
|
4
|
-
BLANK_ATTRS << 'default_hostgroup'
|
5
|
-
|
6
|
-
def self.load_defaults
|
7
|
-
# Check the table exists
|
8
|
-
return unless ActiveRecord::Base.connection.table_exists?('settings')
|
9
|
-
return unless super
|
10
|
-
|
11
|
-
Setting.transaction do
|
12
|
-
[
|
13
|
-
set('force_hostgroup_match', 'Apply hostgroup matching even if a host already has one.', false),
|
14
|
-
set('force_hostgroup_match_only_new', 'Apply hostgroup matching only on new hosts', true),
|
15
|
-
set('force_host_environment', "Apply hostgroup's environment to host even if a host already has a different one", true)
|
16
|
-
].compact.each { |s| create s.update(category: 'Setting::DefaultHostgroup') }
|
17
|
-
end
|
18
|
-
|
19
|
-
true
|
20
|
-
end
|
21
|
-
end
|