foreman_default_hostgroup 5.0.0 → 7.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.
- checksums.yaml +4 -4
- data/README.md +20 -12
- data/db/migrate/20221103122801_fix_default_hostgroup_settings_category_to_dsl.rb +9 -0
- data/lib/default_hostgroup_base_host_patch.rb +22 -19
- data/lib/foreman_default_hostgroup/engine.rb +29 -12
- data/lib/foreman_default_hostgroup/version.rb +1 -1
- data/lib/tasks/foreman_default_hostgroup.rake +2 -2
- data/test/unit/default_hostgroup_test.rb +25 -40
- metadata +9 -10
- data/app/models/setting/default_hostgroup.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e1266d987eb1c009c18ccbcb3d3b7c93da09b277465cead1fce9436bb7547d4
|
4
|
+
data.tar.gz: 88fe5230bca03cdef1808dd28d8f1778e7942db64b1b8716726f7d744cac9136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 937af6365b281ddd5cfc5131d7d4251c3d377bf13fa87e37329345e9dd69368ffbdf855cc26a1a11b937a81f9b9347d0a51ecf5e260d147855c04a59058fda58
|
7
|
+
data.tar.gz: 6d618171ba97d86e839d849dcac811f3ce6d42e92f5338c0f9cacf7010be3168fcc6422ec22ce37d83ce25f786fd649f9a97c6fb42cc64c5fdc02963b2f04cdd
|
data/README.md
CHANGED
@@ -10,15 +10,17 @@ See Foreman's [plugin installation documentation](https://theforeman.org/plugins
|
|
10
10
|
## Compatibility
|
11
11
|
|
12
12
|
| Foreman Version | Plugin Version |
|
13
|
-
| --------------- |
|
14
|
-
| <= 1.2 |
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
| >= 1.12 |
|
20
|
-
| >= 1.16 |
|
21
|
-
| >= 1.16 |
|
13
|
+
| --------------- | -------------: |
|
14
|
+
| <= 1.2 | 0.1.0 |
|
15
|
+
| 1.3 | 1.0.1 |
|
16
|
+
| 1.4 | 1.1.0 |
|
17
|
+
| 1.5 | 2.0.1 |
|
18
|
+
| 1.6 - 1.11 | 3.0.0 |
|
19
|
+
| >= 1.12 | 4.0.0 |
|
20
|
+
| >= 1.16 | 4.0.1 |
|
21
|
+
| >= 1.16 | 5.0.0 |
|
22
|
+
| >= 2.2.0 | 6.0.0 |
|
23
|
+
| >= 3.0 | 7.0.0 |
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
@@ -35,6 +37,12 @@ your needs. The format is shown in the example. The simplest form would be:
|
|
35
37
|
"Default":
|
36
38
|
"hostname": ".*"
|
37
39
|
```
|
40
|
+
|
41
|
+
`Default` is the host group name (more precisely title) that will be assigned if all its the rules matches.
|
42
|
+
Under the host group name, there's a list of rules. If all of them (in this example just one) is matching,
|
43
|
+
the host is assigned to the `Default` host group. The `hostname` is the name of the fact while the value `.*`
|
44
|
+
is used as a regular expression. This rule means host with any `hostname` is added to the `Default` host group.
|
45
|
+
|
38
46
|
If you are ugrading from plugin version 2.0.1 or older the format of this
|
39
47
|
file changes and you will need modify `default_hostgroup.yaml.example` to
|
40
48
|
follow the format above.
|
@@ -44,9 +52,9 @@ follow the format above.
|
|
44
52
|
|
45
53
|
There are also two more settings under `Settings -> DefaultHostgroup`
|
46
54
|
|
47
|
-
| Setting
|
48
|
-
|
|
49
|
-
| `force_hostgroup_match`
|
55
|
+
| Setting | Description |
|
56
|
+
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
57
|
+
| `force_hostgroup_match` | Setting this to `true` will perform matching even on hosts that already have a hostgroup set. Enabling this needs `force_hostgroup_match_only_new` to be `false`. Default: `false` |
|
50
58
|
| `force_hostgroup_match_only_new` | Setting this to `true` will only perform matching when a host uploads its facts for the first time, i.e. after provisioning or when adding an existing puppetmaster and thus its nodes into foreman. Default: `true` |
|
51
59
|
|
52
60
|
## TODO
|
@@ -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')
|
7
|
+
# rubocop:enable Rails/SkipsModelValidations
|
8
|
+
end
|
9
|
+
end
|
@@ -2,13 +2,18 @@ module DefaultHostgroupBaseHostPatch
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
module ManagedOverrides
|
5
|
-
|
5
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
6
|
+
def import_facts(facts, source_proxy = nil, without_alias = false)
|
7
|
+
# rubocop:enable Lint/UnusedMethodArgument
|
6
8
|
super(facts, source_proxy)
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
10
12
|
module Overrides
|
13
|
+
# rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
|
11
14
|
def import_facts(facts, source_proxy = nil, without_alias = false)
|
15
|
+
# rubocop:enable Metrics/AbcSize,Metrics/CyclomaticComplexity
|
16
|
+
|
12
17
|
# Load the facts anyway, hook onto the end of it
|
13
18
|
result = super(facts, source_proxy)
|
14
19
|
|
@@ -19,7 +24,7 @@ module DefaultHostgroupBaseHostPatch
|
|
19
24
|
# Check settings are created
|
20
25
|
return result unless settings_exist?
|
21
26
|
|
22
|
-
Rails.logger.debug
|
27
|
+
Rails.logger.debug "DefaultHostgroupMatch: performing Hostgroup match"
|
23
28
|
|
24
29
|
return result unless host_new_or_forced?
|
25
30
|
return result unless host_has_no_hostgroup_or_forced?
|
@@ -29,12 +34,10 @@ module DefaultHostgroupBaseHostPatch
|
|
29
34
|
|
30
35
|
return result unless new_hostgroup
|
31
36
|
|
32
|
-
self.hostgroup = new_hostgroup
|
33
|
-
if Setting[:force_host_environment] == true
|
34
|
-
|
35
|
-
|
36
|
-
save(validate: false)
|
37
|
-
Rails.logger.info "DefaultHostgroupMatch: #{hostname} added to #{new_hostgroup}"
|
37
|
+
self.host.hostgroup = new_hostgroup
|
38
|
+
self.host.environment = new_hostgroup.environment if Setting[:force_host_environment] == true and facts[:_type] == :puppet
|
39
|
+
self.host.save(validate: false)
|
40
|
+
Rails.logger.info "DefaultHostgroupMatch: #{facts["hostname"]} added to #{new_hostgroup}"
|
38
41
|
|
39
42
|
result
|
40
43
|
end
|
@@ -46,27 +49,27 @@ module DefaultHostgroupBaseHostPatch
|
|
46
49
|
|
47
50
|
def find_match(facts_map)
|
48
51
|
facts_map.each do |group_name, facts|
|
49
|
-
hg = Hostgroup.
|
52
|
+
hg = Hostgroup.find_by(title: group_name)
|
50
53
|
return hg if hg.present? && group_matches?(facts)
|
51
54
|
end
|
52
|
-
Rails.logger.info
|
55
|
+
Rails.logger.info "No match ..."
|
53
56
|
false
|
54
57
|
end
|
55
58
|
|
56
59
|
def group_matches?(facts)
|
57
60
|
facts.each do |fact_name, fact_regex|
|
58
|
-
fact_regex.gsub!(%r{(\A/|/\z)},
|
59
|
-
host_fact_value =
|
61
|
+
fact_regex.gsub!(%r{(\A/|/\z)}, "")
|
62
|
+
host_fact_value = self.host.facts[fact_name]
|
60
63
|
Rails.logger.info "Fact = #{fact_name}"
|
61
64
|
Rails.logger.info "Regex = #{fact_regex}"
|
62
|
-
return true if Regexp.new(fact_regex).match(host_fact_value)
|
65
|
+
return true if Regexp.new(fact_regex).match?(host_fact_value)
|
63
66
|
end
|
64
67
|
false
|
65
68
|
end
|
66
69
|
|
67
70
|
def settings_exist?
|
68
71
|
unless SETTINGS[:default_hostgroup] && SETTINGS[:default_hostgroup][:facts_map]
|
69
|
-
Rails.logger.warn
|
72
|
+
Rails.logger.warn "DefaultHostgroupMatch: Could not load :default_hostgroup map from Settings."
|
70
73
|
return false
|
71
74
|
end
|
72
75
|
true
|
@@ -75,9 +78,9 @@ module DefaultHostgroupBaseHostPatch
|
|
75
78
|
def host_new_or_forced?
|
76
79
|
if Setting[:force_hostgroup_match_only_new]
|
77
80
|
# hosts have already been saved during import_host, so test the creation age instead
|
78
|
-
new_host = ((Time.current - created_at) < 300)
|
79
|
-
unless new_host && hostgroup.nil? && reports.empty?
|
80
|
-
Rails.logger.debug
|
81
|
+
new_host = ((Time.current - self.host.created_at) < 300)
|
82
|
+
unless new_host && self.host.hostgroup.nil? && self.host.reports.empty?
|
83
|
+
Rails.logger.debug "DefaultHostgroupMatch: skipping, host exists"
|
81
84
|
return false
|
82
85
|
end
|
83
86
|
end
|
@@ -86,8 +89,8 @@ module DefaultHostgroupBaseHostPatch
|
|
86
89
|
|
87
90
|
def host_has_no_hostgroup_or_forced?
|
88
91
|
unless Setting[:force_hostgroup_match]
|
89
|
-
if hostgroup.present?
|
90
|
-
Rails.logger.debug
|
92
|
+
if self.host.hostgroup.present?
|
93
|
+
Rails.logger.debug "DefaultHostgroupMatch: skipping, host has hostgroup"
|
91
94
|
return false
|
92
95
|
end
|
93
96
|
end
|
@@ -1,32 +1,49 @@
|
|
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
|
-
|
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
|
13
14
|
end
|
14
15
|
|
15
|
-
initializer
|
16
|
+
initializer "foreman_default_hostgroup.register_plugin",
|
16
17
|
before: :finisher_hook do
|
17
18
|
Foreman::Plugin.register :foreman_default_hostgroup do
|
18
|
-
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
|
19
37
|
end
|
20
38
|
end
|
21
39
|
|
22
40
|
config.to_prepare do
|
23
41
|
begin
|
24
|
-
::
|
25
|
-
::
|
26
|
-
rescue => e
|
42
|
+
::HostFactImporter.include DefaultHostgroupBaseHostPatch
|
43
|
+
::HostFactImporter.prepend DefaultHostgroupBaseHostPatch::ManagedOverrides
|
44
|
+
rescue StandardError => e
|
27
45
|
Rails.logger.warn "ForemanDefaultHostgroup: skipping engine hook (#{e})"
|
28
46
|
end
|
29
47
|
end
|
30
|
-
|
31
48
|
end
|
32
49
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
# Tests
|
3
3
|
namespace :test do
|
4
|
-
desc
|
4
|
+
desc 'Test DefaultHostgroup plugin'
|
5
5
|
Rake::TestTask.new(:foreman_default_hostgroup) do |t|
|
6
6
|
test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
|
7
7
|
t.libs << ['test', test_dir]
|
@@ -20,7 +20,7 @@ namespace :foreman_default_hostgroup do
|
|
20
20
|
"#{ForemanDefaultHostgroup::Engine.root}/lib/**/*.rb",
|
21
21
|
"#{ForemanDefaultHostgroup::Engine.root}/test/**/*.rb"]
|
22
22
|
end
|
23
|
-
rescue
|
23
|
+
rescue StandardError
|
24
24
|
puts 'Rubocop not loaded.'
|
25
25
|
end
|
26
26
|
|
@@ -18,20 +18,20 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
18
18
|
# so we use FactoryBot to re-create it
|
19
19
|
FactoryBot.create(:setting,
|
20
20
|
name: 'force_hostgroup_match',
|
21
|
-
category: 'Setting
|
21
|
+
category: 'Setting')
|
22
22
|
FactoryBot.create(:setting,
|
23
23
|
name: 'force_hostgroup_match_only_new',
|
24
|
-
category: 'Setting
|
24
|
+
category: 'Setting')
|
25
25
|
FactoryBot.create(:setting,
|
26
26
|
name: 'force_host_environment',
|
27
|
-
category: 'Setting
|
27
|
+
category: 'Setting')
|
28
28
|
# Set the defaults
|
29
29
|
Setting[:force_hostgroup_match] = false
|
30
30
|
Setting[:force_hostgroup_match_only_new] = true
|
31
31
|
Setting[:force_host_environment] = true
|
32
32
|
|
33
33
|
# Mimic plugin config fron config file
|
34
|
-
FactoryBot.create(:hostgroup,
|
34
|
+
FactoryBot.create(:hostgroup, name: 'Test Default')
|
35
35
|
SETTINGS[:default_hostgroup] = {}
|
36
36
|
SETTINGS[:default_hostgroup][:facts_map] = {
|
37
37
|
'Test Default' => { 'hostname' => '.*' }
|
@@ -40,15 +40,15 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
40
40
|
|
41
41
|
def setup_host_and_facts
|
42
42
|
raw = JSON.parse(File.read(File.expand_path(File.dirname(__FILE__) + '/facts.json')))
|
43
|
-
@name
|
44
|
-
@host
|
43
|
+
@name = raw['name']
|
44
|
+
@host = Host.import_host(raw['name'], 'puppet')
|
45
45
|
@facts = raw['facts']
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'import_facts_with_match_hostgroup' do
|
49
49
|
test 'matched host is saved with new hostgroup' do
|
50
50
|
assert @host.import_facts(@facts)
|
51
|
-
assert_equal Hostgroup.
|
51
|
+
assert_equal Hostgroup.find_by(name: 'Test Default'), Host.find_by(name: @name).hostgroup
|
52
52
|
end
|
53
53
|
|
54
54
|
test 'matched host not updated if host already has a hostgroup' do
|
@@ -57,7 +57,7 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
57
57
|
@host.save(validate: false)
|
58
58
|
|
59
59
|
assert @host.import_facts(@facts)
|
60
|
-
assert_equal hostgroup, Host.
|
60
|
+
assert_equal hostgroup, Host.find_by(name: @name).hostgroup
|
61
61
|
end
|
62
62
|
|
63
63
|
test 'hostgroup is not updated if host is not new' do
|
@@ -65,22 +65,7 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
65
65
|
@host.save(validate: false)
|
66
66
|
|
67
67
|
assert @host.import_facts(@facts)
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
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
|
-
refute_equal Hostgroup.find_by_name('Test Default').environment, h.environment
|
68
|
+
assert_not Host.find_by(name: @name).hostgroup
|
84
69
|
end
|
85
70
|
end
|
86
71
|
|
@@ -89,33 +74,33 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
89
74
|
test 'match a single hostgroup' do
|
90
75
|
facts_map = SETTINGS[:default_hostgroup][:facts_map]
|
91
76
|
assert @host.import_facts(@facts, nil, true)
|
92
|
-
assert_equal Hostgroup.
|
77
|
+
assert_equal Hostgroup.find_by(name: 'Test Default'), @host.find_match(facts_map)
|
93
78
|
end
|
94
79
|
|
95
80
|
test 'returns false for no match' do
|
96
81
|
facts_map = SETTINGS[:default_hostgroup][:facts_map] = {
|
97
|
-
'Test Default'
|
82
|
+
'Test Default' => { 'hostname' => 'nosuchhost' }
|
98
83
|
}
|
99
84
|
assert @host.import_facts(@facts, nil, true)
|
100
|
-
|
85
|
+
assert_not @host.find_match(facts_map)
|
101
86
|
end
|
102
87
|
|
103
88
|
test 'matches first available hostgroup' do
|
104
89
|
facts_map = SETTINGS[:default_hostgroup][:facts_map] = {
|
105
|
-
'Test Default'
|
90
|
+
'Test Default' => { 'hostname' => '.*' },
|
106
91
|
'Some Other Group' => { 'hostname' => '/\.lan$/' }
|
107
92
|
}
|
108
93
|
assert @host.import_facts(@facts, nil, true)
|
109
|
-
assert_equal Hostgroup.
|
94
|
+
assert_equal Hostgroup.find_by(name: 'Test Default'), @host.find_match(facts_map)
|
110
95
|
end
|
111
96
|
|
112
97
|
test 'nonexistant groups are ignored' do
|
113
98
|
facts_map = SETTINGS[:default_hostgroup][:facts_map] = {
|
114
99
|
'Some Other Group' => { 'hostname' => '.*' },
|
115
|
-
'Test Default'
|
100
|
+
'Test Default' => { 'hostname' => '/\.lan$/' }
|
116
101
|
}
|
117
102
|
assert @host.import_facts(@facts, nil, true)
|
118
|
-
assert_equal Hostgroup.
|
103
|
+
assert_equal Hostgroup.find_by(name: 'Test Default'), @host.find_match(facts_map)
|
119
104
|
end
|
120
105
|
end
|
121
106
|
|
@@ -142,20 +127,20 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
142
127
|
test 'invalid keys are ignored' do
|
143
128
|
regex = { 'nosuchfact' => '.*' }
|
144
129
|
assert @host.import_facts(@facts, nil, true)
|
145
|
-
|
130
|
+
assert_not @host.group_matches?(regex)
|
146
131
|
end
|
147
132
|
|
148
133
|
test 'unmatched values are ignored' do
|
149
134
|
regex = { 'hostname' => 'nosuchname' }
|
150
135
|
assert @host.import_facts(@facts, nil, true)
|
151
|
-
|
136
|
+
assert_not @host.group_matches?(regex)
|
152
137
|
end
|
153
138
|
|
154
139
|
test 'multiple entries with invalid keys / values match' do
|
155
140
|
regex = {
|
156
141
|
'nosuchfact' => '.*',
|
157
|
-
'osfamily'
|
158
|
-
'hostname'
|
142
|
+
'osfamily' => 'nosuchos',
|
143
|
+
'hostname' => '.lan$'
|
159
144
|
}
|
160
145
|
assert @host.import_facts(@facts, nil, true)
|
161
146
|
assert @host.group_matches?(regex)
|
@@ -171,7 +156,7 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
171
156
|
test 'false when Settings are missing' do
|
172
157
|
SETTINGS[:default_hostgroup] = {}
|
173
158
|
h = FactoryBot.create(:host)
|
174
|
-
|
159
|
+
assert_not h.settings_exist?
|
175
160
|
end
|
176
161
|
end
|
177
162
|
|
@@ -183,17 +168,17 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
183
168
|
|
184
169
|
test 'false when host has existed for > 300s' do
|
185
170
|
h = FactoryBot.create(:host, created_at: Time.current - 1000)
|
186
|
-
|
171
|
+
assert_not h.host_new_or_forced?
|
187
172
|
end
|
188
173
|
|
189
174
|
test 'false when host has a hostgroup' do
|
190
175
|
h = FactoryBot.create(:host, :with_hostgroup, created_at: Time.current)
|
191
|
-
|
176
|
+
assert_not h.host_new_or_forced?
|
192
177
|
end
|
193
178
|
|
194
179
|
test 'false when host has reports' do
|
195
180
|
h = FactoryBot.create(:host, :with_reports, created_at: Time.current)
|
196
|
-
|
181
|
+
assert_not h.host_new_or_forced?
|
197
182
|
end
|
198
183
|
|
199
184
|
test 'true when setting is forced' do
|
@@ -211,7 +196,7 @@ class DefaultHostgroupTest < ActiveSupport::TestCase
|
|
211
196
|
|
212
197
|
test 'false if host has hostgroup' do
|
213
198
|
h = FactoryBot.create(:host, :with_hostgroup)
|
214
|
-
|
199
|
+
assert_not h.host_has_no_hostgroup_or_forced?
|
215
200
|
end
|
216
201
|
|
217
202
|
test 'true if host has hostgroup and setting forced' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_default_hostgroup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 7.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sutcliffe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Adds the option to specify a default hostgroup for new hosts created
|
14
14
|
from facts/reports
|
@@ -21,7 +21,7 @@ extra_rdoc_files:
|
|
21
21
|
files:
|
22
22
|
- LICENSE
|
23
23
|
- README.md
|
24
|
-
-
|
24
|
+
- db/migrate/20221103122801_fix_default_hostgroup_settings_category_to_dsl.rb
|
25
25
|
- default_hostgroup.yaml.example
|
26
26
|
- lib/default_hostgroup_base_host_patch.rb
|
27
27
|
- lib/foreman_default_hostgroup.rb
|
@@ -31,11 +31,11 @@ files:
|
|
31
31
|
- test/test_plugin_helper.rb
|
32
32
|
- test/unit/default_hostgroup_test.rb
|
33
33
|
- test/unit/facts.json
|
34
|
-
homepage:
|
34
|
+
homepage: https://github.com/theforeman/foreman_default_hostgroup
|
35
35
|
licenses:
|
36
|
-
- GPL-3
|
36
|
+
- GPL-3.0
|
37
37
|
metadata: {}
|
38
|
-
post_install_message:
|
38
|
+
post_install_message:
|
39
39
|
rdoc_options: []
|
40
40
|
require_paths:
|
41
41
|
- lib
|
@@ -50,9 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
50
|
- !ruby/object:Gem::Version
|
51
51
|
version: '0'
|
52
52
|
requirements: []
|
53
|
-
|
54
|
-
|
55
|
-
signing_key:
|
53
|
+
rubygems_version: 3.3.26
|
54
|
+
signing_key:
|
56
55
|
specification_version: 4
|
57
56
|
summary: Default Hostgroup Plugin for Foreman
|
58
57
|
test_files:
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class Setting::DefaultHostgroup < ::Setting
|
2
|
-
BLANK_ATTRS << 'default_hostgroup'
|
3
|
-
|
4
|
-
def self.load_defaults
|
5
|
-
# Check the table exists
|
6
|
-
return unless ActiveRecord::Base.connection.table_exists?('settings')
|
7
|
-
return unless super
|
8
|
-
|
9
|
-
Setting.transaction do
|
10
|
-
[
|
11
|
-
set('force_hostgroup_match', 'Apply hostgroup matching even if a host already has one.', false),
|
12
|
-
set('force_hostgroup_match_only_new', 'Apply hostgroup matching only on new hosts', true),
|
13
|
-
set('force_host_environment', "Apply hostgroup's environment to host even if a host already has a different one", true)
|
14
|
-
].compact.each { |s| create s.update(category: 'Setting::DefaultHostgroup') }
|
15
|
-
end
|
16
|
-
|
17
|
-
true
|
18
|
-
end
|
19
|
-
end
|