foreman_puppet 2.0.0.alpha.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +41 -32
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb +37 -28
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +1 -1
- data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
- data/app/models/foreman_puppet/host_puppet_facet.rb +1 -1
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +2 -0
- data/app/views/foreman_puppet/config_groups/index.html.erb +1 -1
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +36 -20
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +0 -8
- data/db/migrate/20211111125003_drop_puppetclasses_direct_references.foreman_puppet.rb +11 -0
- data/db/migrate/20211112130803_cleanup_environment_from_core_tables.foreman_puppet.rb +10 -0
- data/db/migrate_foreman/{20090722141107_create_environments.rb → 20090722141107_create_environments.foreman_puppet.rb} +1 -1
- data/db/migrate_foreman/{20090802062223_create_puppetclasses.rb → 20090802062223_create_puppetclasses.foreman_puppet.rb} +3 -2
- data/db/migrate_foreman/{20090905150132_create_hostgroups_puppetclasses.rb → 20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20110412103238_remove_unused_fields_from_puppet_classes.rb → 20110412103238_remove_unused_fields_from_puppet_classes.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20110712070522_create_host_class.rb → 20110712070522_create_host_class.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20120824142048_add_some_indexes.rb → 20120824142048_add_some_indexes.foreman_puppet.rb} +8 -1
- 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.rb → 20121018152459_create_hostgroup_classes.foreman_puppet.rb} +0 -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} +0 -0
- 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.rb → 20180816134832_cast_lookup_key_values.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20180831115634_add_uniqueness_to_puppetclass_name.rb → 20180831115634_add_uniqueness_to_puppetclass_name.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20181023112532_add_environment_puppetclass_id.rb → 20181023112532_add_environment_puppetclass_id.foreman_puppet.rb} +0 -0
- 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/register.rb +35 -0
- data/lib/foreman_puppet/version.rb +1 -1
- 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.edit.po +1085 -0
- data/locale/cs_CZ/foreman_puppet.po +823 -0
- data/locale/cs_CZ/foreman_puppet.po.time_stamp +0 -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.edit.po +317 -162
- data/locale/en/foreman_puppet.po +58 -1
- 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 +181 -92
- data/locale/fr/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/fr/foreman_puppet.po +835 -0
- 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/test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb +70 -31
- data/test/integration/foreman_puppet/dashboard_js_test.rb +31 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +7 -1
- metadata +64 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c850f32331462f52510a8e895c149eb470e9982ad819de78529c38c888ab549c
|
|
4
|
+
data.tar.gz: 81460cb582b62baa3f96083c3573a99607a9b2619d2a20c31df4f41da48677c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f0b20469d894d6a1cc2e8c6f486ef5f09dd9c04742c0be684f68846fe930536a813ee404fb30af2ba0ae9031df6c2c00ea3a4af0233be5b24640b81d2a58d031
|
|
7
|
+
data.tar.gz: 16cab8e0431a72b04795046e4e66ca67a029247f4bf182a7a3f36e7ec8f2c5d45a1ae3db4ce8d96a48869a698eebec284eef6d9c0290d10270c41ab19789d0ee
|
|
@@ -14,12 +14,7 @@ module ForemanPuppet
|
|
|
14
14
|
module PatchedClassMethods
|
|
15
15
|
def host_params_filter
|
|
16
16
|
super.tap do |filter|
|
|
17
|
-
filter
|
|
18
|
-
config_groups: [], config_group_ids: [], config_group_names: [],
|
|
19
|
-
puppetclasses: [], puppetclass_ids: [], puppetclass_names: []
|
|
20
|
-
|
|
21
|
-
# TODO: bring to core - this is what facets should do, but does not
|
|
22
|
-
filter.permit(puppet_attributes: {})
|
|
17
|
+
add_host_puppet_params_filter(filter)
|
|
23
18
|
end
|
|
24
19
|
end
|
|
25
20
|
end
|
|
@@ -27,40 +22,54 @@ module ForemanPuppet
|
|
|
27
22
|
module PatchedMethods
|
|
28
23
|
def host_params(*attrs)
|
|
29
24
|
params = super(*attrs)
|
|
30
|
-
|
|
31
|
-
process_deprecated_environment_params!(params)
|
|
32
|
-
process_deprecated_attributes!(params)
|
|
25
|
+
process_deprecated_puppet_params!(params)
|
|
33
26
|
params
|
|
34
27
|
end
|
|
28
|
+
end
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return unless env_id || env_name || env
|
|
42
|
-
::Foreman::Deprecation.api_deprecation_warning('param host[environment_*] has been deprecated in favor of host[puppet_attributes][environment_*]')
|
|
30
|
+
class_methods do
|
|
31
|
+
def add_host_puppet_params_filter(filter)
|
|
32
|
+
filter.permit :environment_id, :environment_name, :environment,
|
|
33
|
+
config_groups: [], config_group_ids: [], config_group_names: [],
|
|
34
|
+
puppetclasses: [], puppetclass_ids: [], puppetclass_names: []
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
params[:puppet_attributes][:environment_name] ||= env_name if env_name
|
|
47
|
-
params[:puppet_attributes][:environment] ||= env if env
|
|
36
|
+
# TODO: bring to core - this is what facets should do, but does not
|
|
37
|
+
filter.permit(puppet_attributes: {})
|
|
48
38
|
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def process_deprecated_puppet_params!(params, top_level_hash = controller_name.singularize)
|
|
42
|
+
process_deprecated_environment_params!(params, top_level_hash)
|
|
43
|
+
process_deprecated_attributes!(params, top_level_hash)
|
|
44
|
+
end
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
plains = params.delete(relation.pluralize.to_sym)
|
|
46
|
+
def process_deprecated_environment_params!(params, top_level_hash = 'host')
|
|
47
|
+
env_id = params.delete(:environment_id)
|
|
48
|
+
env_name = params.delete(:environment_name)
|
|
49
|
+
env = params.delete(:environment)
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
return unless env_id || env_name || env
|
|
52
|
+
::Foreman::Deprecation.api_deprecation_warning("param #{top_level_hash}[environment_*] has been deprecated in favor of #{top_level_hash}[puppet_attributes][environment_*]")
|
|
58
53
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
params[:puppet_attributes] ||= {}
|
|
55
|
+
params[:puppet_attributes][:environment_id] ||= env_id if env_id
|
|
56
|
+
params[:puppet_attributes][:environment_name] ||= env_name if env_name
|
|
57
|
+
params[:puppet_attributes][:environment] ||= env if env
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def process_deprecated_attributes!(params, top_level_hash = 'host')
|
|
61
|
+
%w[puppetclass config_group].each do |relation|
|
|
62
|
+
ids = params.delete("#{relation}_ids".to_sym)
|
|
63
|
+
names = params.delete("#{relation}_names".to_sym)
|
|
64
|
+
plains = params.delete(relation.pluralize.to_sym)
|
|
65
|
+
|
|
66
|
+
next unless ids || names || plains
|
|
67
|
+
::Foreman::Deprecation.api_deprecation_warning("param #{top_level_hash}[#{relation}_*] has been deprecated in favor of #{top_level_hash}[puppet_attributes][#{relation}_*]")
|
|
68
|
+
|
|
69
|
+
params[:puppet_attributes] ||= {}
|
|
70
|
+
params[:puppet_attributes]["#{relation}_ids".to_sym] ||= ids if ids
|
|
71
|
+
params[:puppet_attributes]["#{relation}_names".to_sym] ||= names if names
|
|
72
|
+
params[:puppet_attributes][relation.pluralize.to_sym] ||= plains if plains
|
|
64
73
|
end
|
|
65
74
|
end
|
|
66
75
|
end
|
|
@@ -14,12 +14,7 @@ module ForemanPuppet
|
|
|
14
14
|
module PatchedClassMethods
|
|
15
15
|
def hostgroup_params_filter
|
|
16
16
|
super.tap do |filter|
|
|
17
|
-
filter
|
|
18
|
-
config_group_ids: [], config_group_names: [],
|
|
19
|
-
puppetclass_ids: [], puppetclass_names: []
|
|
20
|
-
|
|
21
|
-
# TODO: bring to core - this is what facets should do, but does not
|
|
22
|
-
filter.permit(puppet_attributes: {})
|
|
17
|
+
add_hostgroup_puppet_params_filter(filter)
|
|
23
18
|
end
|
|
24
19
|
end
|
|
25
20
|
end
|
|
@@ -27,36 +22,50 @@ module ForemanPuppet
|
|
|
27
22
|
module PatchedMethods
|
|
28
23
|
def hostgroup_params(*attrs)
|
|
29
24
|
params = super(*attrs)
|
|
30
|
-
|
|
31
|
-
process_deprecated_hostgroup_environment_params!(params)
|
|
32
|
-
process_deprecated_hostgroup_attributes!(params)
|
|
25
|
+
process_deprecated_hostgroup_puppet_params!(params)
|
|
33
26
|
params
|
|
34
27
|
end
|
|
28
|
+
end
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
::Foreman::Deprecation.api_deprecation_warning('param hostgroup[environment_*] has been deprecated in favor of hostgroup[puppet_attributes][environment_*]')
|
|
30
|
+
class_methods do
|
|
31
|
+
def add_hostgroup_puppet_params_filter(filter)
|
|
32
|
+
filter.permit :environment_id, :environment_name,
|
|
33
|
+
config_group_ids: [], config_group_names: [],
|
|
34
|
+
puppetclass_ids: [], puppetclass_names: []
|
|
42
35
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
params[:puppet_attributes][:environment_name] ||= env_name if env_name
|
|
36
|
+
# TODO: bring to core - this is what facets should do, but does not
|
|
37
|
+
filter.permit(puppet_attributes: {})
|
|
46
38
|
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def process_deprecated_hostgroup_puppet_params!(params, top_level_hash = 'hostgroup')
|
|
42
|
+
process_deprecated_hostgroup_environment_params!(params, top_level_hash)
|
|
43
|
+
process_deprecated_hostgroup_attributes!(params, top_level_hash)
|
|
44
|
+
end
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
names = params.delete("#{relation}_names")
|
|
46
|
+
def process_deprecated_hostgroup_environment_params!(params, top_level_hash = 'hostgroup')
|
|
47
|
+
env_id = params.delete(:environment_id)
|
|
48
|
+
env_name = params.delete(:environment_name)
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
return unless env_id || env_name
|
|
51
|
+
::Foreman::Deprecation.api_deprecation_warning("param #{top_level_hash}[environment_*] has been deprecated in favor of #{top_level_hash}[puppet_attributes][environment_*]")
|
|
55
52
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
53
|
+
params[:puppet_attributes] ||= {}
|
|
54
|
+
params[:puppet_attributes][:environment_id] ||= env_id if env_id
|
|
55
|
+
params[:puppet_attributes][:environment_name] ||= env_name if env_name
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def process_deprecated_hostgroup_attributes!(params, top_level_hash = 'hostgroup')
|
|
59
|
+
%w[puppetclass config_group].each do |relation|
|
|
60
|
+
ids = params.delete("#{relation}_ids")
|
|
61
|
+
names = params.delete("#{relation}_names")
|
|
62
|
+
|
|
63
|
+
next unless ids || names
|
|
64
|
+
::Foreman::Deprecation.api_deprecation_warning("param #{top_level_hash}[#{relation}_*] has been deprecated in favor of #{top_level_hash}[puppet_attributes][#{relation}_*]")
|
|
65
|
+
|
|
66
|
+
params[:puppet_attributes] ||= {}
|
|
67
|
+
params[:puppet_attributes]["#{relation}_ids".to_sym] ||= ids if ids
|
|
68
|
+
params[:puppet_attributes]["#{relation}_names".to_sym] ||= names if names
|
|
60
69
|
end
|
|
61
70
|
end
|
|
62
71
|
end
|
|
@@ -20,7 +20,7 @@ module ForemanPuppet
|
|
|
20
20
|
|
|
21
21
|
def create
|
|
22
22
|
@hostgroup_class = HostgroupClass.create!(hostgroup_puppet_facet_id: @hostgroup.puppet.id, puppetclass_id: params[:puppetclass_id].to_i)
|
|
23
|
-
render json: { hostgroup_id: @
|
|
23
|
+
render json: { hostgroup_id: @hostgroup.puppet.hostgroup_id, puppetclass_id: @hostgroup_class.puppetclass_id }
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
api :DELETE, '/hostgroups/:hostgroup_id/puppetclass_ids/:id/', N_('Remove a Puppet class from host group')
|
|
@@ -10,7 +10,7 @@ module ForemanPuppet
|
|
|
10
10
|
|
|
11
11
|
def environments_title_actions
|
|
12
12
|
title_actions import_proxy_select(hash_for_import_environments_environments_path.merge(engine: foreman_puppet)),
|
|
13
|
-
button_group(new_link(_('Create Puppet Environment'), engine: foreman_puppet)),
|
|
13
|
+
button_group(new_link(_('Create Puppet Environment'), { engine: foreman_puppet }, id: 'new_environment')),
|
|
14
14
|
button_group(help_button)
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -48,6 +48,8 @@ module ForemanPuppet
|
|
|
48
48
|
Hostgroup.sort_by_ancestry(hostgroup.ancestors.joins(:puppet).where(HostgroupPuppetFacet.arel_table[attr.to_sym].not_eq(nil))).last&.puppet.try(attr)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
delegate :parent_id, to: :hostgroup
|
|
52
|
+
|
|
51
53
|
# and helpers
|
|
52
54
|
def parent_facet_id
|
|
53
55
|
parent_facet&.id
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<% content_for(:search_bar) { } %>
|
|
3
3
|
<% title _('Config Groups') %>
|
|
4
4
|
|
|
5
|
-
<% title_actions new_link(_('Create Config Group'), engine: foreman_puppet), help_button %>
|
|
5
|
+
<% title_actions new_link(_('Create Config Group'), { engine: foreman_puppet }, id: 'new_config_group'), help_button %>
|
|
6
6
|
|
|
7
7
|
<table class="<%= table_css_classes 'table-fixed' %>">
|
|
8
8
|
<thead>
|
|
@@ -13,26 +13,8 @@ class MigrateHostTypeInHostConfigGroups < ActiveRecord::Migration[6.0]
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def up
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
host_facet_id = ForemanPuppet::HostPuppetFacet.where(host_id: host_id).pick(:id)
|
|
19
|
-
host_groups = FakeHostConfigGroup.for_host.where(host_id: host_id)
|
|
20
|
-
if host_facet_id
|
|
21
|
-
host_groups.update_all(host_type: 'ForemanPuppet::HostPuppetFacet', host_id: host_facet_id)
|
|
22
|
-
else
|
|
23
|
-
deleted_groups = FakeConfigGroup.where(id: host_groups.pluck(:config_group_id)).pluck(:name)
|
|
24
|
-
say "deleting groups #{deleted_groups.join(', ')} from Host (id=#{host_id}) because it has no environment"
|
|
25
|
-
host_groups.delete_all
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
hostgroup_config_group_ids = FakeHostConfigGroup.for_hostgroup.pluck(:host_id).uniq
|
|
29
|
-
hostgroup_config_group_ids.each do |hostgroup_id|
|
|
30
|
-
hostgroup_facet_id = ForemanPuppet::HostgroupPuppetFacet.where(hostgroup_id: hostgroup_id).pick(:id)
|
|
31
|
-
hostgroup_facet_id ||= ForemanPuppet::HostgroupPuppetFacet.create!(hostgroup: Hostgroup.unscoped.find(hostgroup_id)).id
|
|
32
|
-
FakeHostConfigGroup.for_hostgroup
|
|
33
|
-
.where(host_id: hostgroup_id)
|
|
34
|
-
.update_all(host_type: 'ForemanPuppet::HostgroupPuppetFacet', host_id: hostgroup_facet_id)
|
|
35
|
-
end
|
|
16
|
+
migrate_host_data_to_facets
|
|
17
|
+
migrate_hostgroup_data_to_facets
|
|
36
18
|
end
|
|
37
19
|
|
|
38
20
|
def down
|
|
@@ -51,4 +33,38 @@ class MigrateHostTypeInHostConfigGroups < ActiveRecord::Migration[6.0]
|
|
|
51
33
|
.update_all(host_type: 'Hostgroup', host_id: hostgroup_facet_ids[hostgroup_facet_id])
|
|
52
34
|
end
|
|
53
35
|
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def migrate_host_data_to_facets
|
|
40
|
+
host_config_group_ids = FakeHostConfigGroup.for_host.pluck(:host_id).uniq
|
|
41
|
+
host_config_group_ids.each do |host_id|
|
|
42
|
+
host_facet_id = ForemanPuppet::HostPuppetFacet.where(host_id: host_id).pick(:id)
|
|
43
|
+
host_groups = FakeHostConfigGroup.for_host.where(host_id: host_id)
|
|
44
|
+
if host_facet_id
|
|
45
|
+
host_groups.update_all(host_type: 'ForemanPuppet::HostPuppetFacet', host_id: host_facet_id)
|
|
46
|
+
else
|
|
47
|
+
deleted_groups = FakeConfigGroup.where(id: host_groups.pluck(:config_group_id)).pluck(:name)
|
|
48
|
+
say "Deleting Config groups #{deleted_groups.join(', ')} from Host (id=#{host_id}) because the Host doesn't exist or has no environment"
|
|
49
|
+
host_groups.delete_all
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def migrate_hostgroup_data_to_facets
|
|
55
|
+
hostgroup_config_group_ids = FakeHostConfigGroup.for_hostgroup.pluck(:host_id).uniq
|
|
56
|
+
hostgroup_config_group_ids.each do |hostgroup_id|
|
|
57
|
+
hostgroup = Hostgroup.unscoped.find_by(id: hostgroup_id)
|
|
58
|
+
hostgroup_groups = FakeHostConfigGroup.for_hostgroup.where(host_id: hostgroup_id)
|
|
59
|
+
if hostgroup
|
|
60
|
+
hostgroup_facet_id = ForemanPuppet::HostgroupPuppetFacet.where(hostgroup_id: hostgroup_id).pick(:id)
|
|
61
|
+
hostgroup_facet_id ||= ForemanPuppet::HostgroupPuppetFacet.create!(hostgroup: hostgroup).id
|
|
62
|
+
hostgroup_groups.update_all(host_type: 'ForemanPuppet::HostgroupPuppetFacet', host_id: hostgroup_facet_id)
|
|
63
|
+
else
|
|
64
|
+
deleted_groups = FakeConfigGroup.where(id: hostgroup_groups.pluck(:config_group_id)).pluck(:name)
|
|
65
|
+
say "Deleting Config groups #{deleted_groups.join(', ')} from Hostgroup (id=#{hostgroup_id}) because Hostgroup doesn't exist"
|
|
66
|
+
hostgroup_groups.delete_all
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
54
70
|
end
|
|
@@ -33,17 +33,9 @@ class MigratePuppetclassesToFacets < ActiveRecord::Migration[6.0]
|
|
|
33
33
|
hostgroup_facet ||= ForemanPuppet::HostgroupPuppetFacet.create(hostgroup: Hostgroup.unscoped.find(hostgroup_id))
|
|
34
34
|
ForemanPuppet::HostgroupClass.where(hostgroup_id: hostgroup_id).update_all(hostgroup_puppet_facet_id: hostgroup_facet.id)
|
|
35
35
|
end
|
|
36
|
-
|
|
37
|
-
change_column_null(:host_classes, :host_id, true)
|
|
38
|
-
change_column_null(:hostgroup_classes, :hostgroup_id, true)
|
|
39
|
-
# remove_reference(:host_classes, :host, index: true, foreign_key: true)
|
|
40
|
-
# remove_reference(:hostgroup_classes, :hostgroup, index: true, foreign_key: true)
|
|
41
36
|
end
|
|
42
37
|
|
|
43
38
|
def down
|
|
44
|
-
# add_reference :host_classes, :host, foreign_key: true, index: true
|
|
45
|
-
# add_reference :hostgroup_classes, :hostgroup, foreign_key: true, index: true
|
|
46
|
-
|
|
47
39
|
host_facets_ids = ForemanPuppet::HostClass.joins(:host_puppet_facet).pluck(:host_puppet_facet_id, 'host_puppet_facets.host_id')
|
|
48
40
|
host_facets_ids.each do |host_facet_id, host_id|
|
|
49
41
|
ForemanPuppet::HostClass.where(host_puppet_facet_id: host_facet_id).update_all(host_id: host_id)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class DropPuppetclassesDirectReferences < ActiveRecord::Migration[6.0]
|
|
2
|
+
def up
|
|
3
|
+
remove_reference(:host_classes, :host, index: true, foreign_key: true)
|
|
4
|
+
remove_reference(:hostgroup_classes, :hostgroup, index: true, foreign_key: true)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def down
|
|
8
|
+
add_reference :host_classes, :host, foreign_key: true, index: true
|
|
9
|
+
add_reference :hostgroup_classes, :hostgroup, foreign_key: true, index: true
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class CleanupEnvironmentFromCoreTables < ActiveRecord::Migration[6.0]
|
|
2
|
+
def up
|
|
3
|
+
::Hostgroup.update_all(environment_id: nil) if column_exists?(:hostgroups, :environment_id)
|
|
4
|
+
Host::Managed.update_all(environment_id: nil) if column_exists?(:hosts, :environment_id)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def down
|
|
8
|
+
# nothing to do
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -21,8 +21,9 @@ class CreatePuppetclasses < ActiveRecord::Migration[4.2]
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def down
|
|
24
|
-
drop_table :puppetclasses
|
|
25
|
-
drop_table :hosts_puppetclasses
|
|
26
24
|
drop_table :operatingsystems_puppetclasses
|
|
25
|
+
drop_table :hosts_puppetclasses
|
|
26
|
+
remove_foreign_key(:environments_puppetclasses, :puppetclasses)
|
|
27
|
+
drop_table :puppetclasses
|
|
27
28
|
end
|
|
28
29
|
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class AddSomeIndexes < ActiveRecord::Migration[4.2]
|
|
2
|
-
def
|
|
2
|
+
def up
|
|
3
3
|
# puppetclasses
|
|
4
4
|
add_index :puppetclasses, :name
|
|
5
5
|
|
|
@@ -11,4 +11,11 @@ class AddSomeIndexes < ActiveRecord::Migration[4.2]
|
|
|
11
11
|
add_foreign_key 'operatingsystems_puppetclasses', 'operatingsystems', name: 'operatingsystems_puppetclasses_operatingsystem_id_fk'
|
|
12
12
|
add_foreign_key 'operatingsystems_puppetclasses', 'puppetclasses', name: 'operatingsystems_puppetclasses_puppetclass_id_fk'
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
def down
|
|
16
|
+
remove_foreign_key 'host_classes', 'hosts', name: 'host_classes_host_id_fk'
|
|
17
|
+
remove_foreign_key 'host_classes', 'puppetclasses', name: 'host_classes_puppetclass_id_fk'
|
|
18
|
+
remove_foreign_key 'operatingsystems_puppetclasses', 'operatingsystems', name: 'operatingsystems_puppetclasses_operatingsystem_id_fk'
|
|
19
|
+
remove_foreign_key 'operatingsystems_puppetclasses', 'puppetclasses', name: 'operatingsystems_puppetclasses_puppetclass_id_fk'
|
|
20
|
+
end
|
|
14
21
|
end
|
|
@@ -8,8 +8,8 @@ class CreateEnvironmentClasses < ActiveRecord::Migration[5.0]
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def down
|
|
11
|
-
remove_foreign_key :environment_classes, :
|
|
12
|
-
|
|
11
|
+
remove_foreign_key :environment_classes, :lookup_keys, column: :puppetclass_lookup_key_id
|
|
12
|
+
remove_column :environment_classes, :puppetclass_lookup_key_id, :integer
|
|
13
13
|
rename_table :environment_classes, :environments_puppetclasses
|
|
14
14
|
end
|
|
15
15
|
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -3,6 +3,41 @@ Foreman::Plugin.register :foreman_puppet do
|
|
|
3
3
|
# Add Global JS file for extending foreman-core components and routes
|
|
4
4
|
register_global_js_file 'fills'
|
|
5
5
|
|
|
6
|
+
settings do
|
|
7
|
+
category(:facts, N_('Facts')) do
|
|
8
|
+
setting('default_puppet_environment',
|
|
9
|
+
type: :string,
|
|
10
|
+
description: N_('Foreman will default to this puppet environment if it cannot auto detect one'),
|
|
11
|
+
default: 'production',
|
|
12
|
+
full_name: N_('Default Puppet environment'),
|
|
13
|
+
collection: proc { ForemanPuppet::Environment.pluck(:name).map { |name| [name, name] }.to_h })
|
|
14
|
+
setting('enc_environment',
|
|
15
|
+
type: :boolean,
|
|
16
|
+
description: N_('Foreman will explicitly set the puppet environment in the ENC yaml output. '\
|
|
17
|
+
'This will avoid conflicts between the environment in puppet.conf and the environment set in Foreman'),
|
|
18
|
+
default: true,
|
|
19
|
+
full_name: N_('ENC environment'))
|
|
20
|
+
setting('update_environment_from_facts',
|
|
21
|
+
type: :boolean,
|
|
22
|
+
description: N_("Foreman will update a host's environment from its facts"),
|
|
23
|
+
default: false,
|
|
24
|
+
full_name: N_('Update environment from facts'))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
category(:cfgmgmt, N_('Config Management')) do
|
|
28
|
+
setting('puppet_interval',
|
|
29
|
+
type: :integer,
|
|
30
|
+
description: N_('Duration in minutes after servers reporting via Puppet are classed as out of sync.'),
|
|
31
|
+
default: 35,
|
|
32
|
+
full_name: N_('Puppet interval'))
|
|
33
|
+
setting('puppet_out_of_sync_disabled',
|
|
34
|
+
type: :boolean,
|
|
35
|
+
description: N_('Disable host configuration status turning to out of sync for %s after report does not arrive within configured interval') % 'Puppet',
|
|
36
|
+
default: false,
|
|
37
|
+
full_name: N_('%s out of sync disabled') % 'Puppet')
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
6
41
|
apipie_documented_controllers(["#{ForemanPuppet::Engine.root}/app/controllers/foreman_puppet/api/v2/*.rb"])
|
|
7
42
|
|
|
8
43
|
# TODO: maybe this would not be necessary if we rething the form
|
|
Binary file
|