foreman_puppet 1.0.5 → 2.0.3
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/api_hostgroups_controller.rb +14 -16
- data/app/controllers/concerns/foreman_puppet/{api/import_puppetclasses_common_controller.rb → extensions/api_smart_proxies_controller.rb} +9 -3
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +23 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_v2_hosts_controller.rb +15 -17
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +0 -1
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb +2 -8
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +0 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +1 -1
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +1 -1
- data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/hosts_and_hostgroups_helper.rb +0 -5
- data/app/helpers/foreman_puppet/hosts_helper.rb +6 -10
- data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/host.rb +2 -16
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +2 -7
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +7 -12
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +5 -10
- data/app/services/foreman_puppet/puppet_class_importer.rb +0 -6
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/host_list.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/base.json.rabl +2 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_list.json.rabl +3 -0
- data/app/views/foreman_puppet/config_groups/index.html.erb +1 -1
- data/config/api_routes.rb +1 -9
- data/config/initializers/api_reroute.rb +73 -5
- data/db/migrate/20101121140000_add_environment_to_template_combinations.foreman_puppet.rb +1 -1
- data/db/migrate/20200803113803_migrate_environment_to_puppet_facet.foreman_puppet.rb +2 -0
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +0 -8
- data/db/migrate/20210924103241_remove_katello_id_from_environments.foreman_puppet.rb +5 -0
- data/db/migrate/20211111125003_drop_puppetclasses_direct_references.foreman_puppet.rb +11 -0
- data/db/migrate/20220201205305_migrate_host_class_permission.foreman_puppet.rb +9 -0
- data/db/migrate/20220208135305_migrate_environment_ignore_type.foreman_puppet.rb +15 -0
- data/db/migrate_foreman/{20090722141107_create_environments.rb → 20090722141107_create_environments.foreman_puppet.rb} +3 -3
- data/db/migrate_foreman/20090802062223_create_puppetclasses.foreman_puppet.rb +29 -0
- data/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb +14 -0
- data/db/migrate_foreman/20110412103238_remove_unused_fields_from_puppet_classes.foreman_puppet.rb +9 -0
- data/db/migrate_foreman/20110712070522_create_host_class.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb +21 -0
- data/db/migrate_foreman/{20120905095532_create_environment_classes.rb → 20120905095532_create_environment_classes.foreman_puppet.rb} +2 -2
- data/db/migrate_foreman/20121018152459_create_hostgroup_classes.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/{20140407161817_create_config_groups.rb → 20140407161817_create_config_groups.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20140407162007_create_config_group_classes.rb → 20140407162007_create_config_group_classes.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20140407162059_create_host_config_groups.rb → 20140407162059_create_host_config_groups.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20161205142618_delete_orphaned_smart_class_parameters.rb → 20161205142618_delete_orphaned_smart_class_parameters.foreman_puppet.rb} +1 -1
- data/db/migrate_foreman/{20170109115157_fix_lookup_key_auditable_type.rb → 20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.foreman_puppet.rb +5 -0
- data/db/migrate_foreman/20180831115634_add_uniqueness_to_puppetclass_name.foreman_puppet.rb +24 -0
- data/db/migrate_foreman/{20181023112532_add_environment_puppetclass_id.rb → 20181023112532_add_environment_puppetclass_id.foreman_puppet.rb} +1 -1
- data/db/migrate_foreman/{20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.rb → 20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.foreman_puppet.rb} +0 -0
- data/lib/foreman_puppet/engine.rb +4 -36
- data/lib/foreman_puppet/register.rb +51 -46
- data/lib/foreman_puppet/version.rb +1 -1
- data/lib/foreman_puppet.rb +1 -6
- data/locale/ca/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ca/foreman_puppet.po +760 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/cs_CZ/foreman_puppet.po +823 -0
- data/locale/de/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/de/foreman_puppet.po +844 -0
- data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en/foreman_puppet.po +119 -8
- data/locale/en_GB/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en_GB/foreman_puppet.po +820 -0
- data/locale/es/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/es/foreman_puppet.po +827 -0
- data/locale/foreman_puppet.pot +376 -205
- data/locale/fr/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/fr/foreman_puppet.po +835 -0
- data/locale/gemspec.rb +1 -1
- data/locale/gl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/gl/foreman_puppet.po +818 -0
- data/locale/it/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/it/foreman_puppet.po +822 -0
- data/locale/ja/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ja/foreman_puppet.po +830 -0
- data/locale/ko/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ko/foreman_puppet.po +819 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/nl_NL/foreman_puppet.po +823 -0
- data/locale/pl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pl/foreman_puppet.po +822 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pt_BR/foreman_puppet.po +826 -0
- data/locale/ru/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ru/foreman_puppet.po +827 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/sv_SE/foreman_puppet.po +822 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_CN/foreman_puppet.po +831 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_TW/foreman_puppet.po +821 -0
- data/package.json +8 -11
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +0 -231
- data/test/controllers/foreman_puppet/api/v2/smart_proxies_controller_test.rb +255 -0
- data/test/controllers/foreman_puppet/environments_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/hosts_controller_test.rb +0 -1
- data/test/factories/foreman_puppet_factories.rb +0 -2
- data/test/helpers/foreman_puppet/puppetclass_lookup_keys_helper_test.rb +34 -0
- data/test/integration/foreman_puppet/dashboard_js_test.rb +31 -0
- data/test/integration/foreman_puppet/host_js_test.rb +0 -1
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +1 -1
- data/test/models/foreman_puppet/host_test.rb +26 -0
- data/test/models/foreman_puppet/user_test.rb +1 -5
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +1 -1
- metadata +69 -16
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.rb +0 -35
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class MigrateEnvironmentIgnoreType < ActiveRecord::Migration[6.0]
|
|
2
|
+
def up
|
|
3
|
+
taxonomies = Taxonomy.unscoped.where("ignore_types LIKE '%Environment%'")
|
|
4
|
+
environment_ids = ForemanPuppet::Environment.unscoped.pluck(:id)
|
|
5
|
+
|
|
6
|
+
taxonomies.each do |tax|
|
|
7
|
+
new_types = tax.ignore_types.reject { |type| type == 'Environment' }
|
|
8
|
+
tax.update_columns(ignore_types: new_types)
|
|
9
|
+
taxable_rows = environment_ids.map do |env_id|
|
|
10
|
+
{ taxable_id: env_id, taxable_type: 'ForemanPuppet::Environment', taxonomy_id: tax.id }
|
|
11
|
+
end
|
|
12
|
+
TaxableTaxonomy.insert_all(taxable_rows) if taxable_rows.any?
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
class CreateEnvironments < ActiveRecord::Migration[
|
|
1
|
+
class CreateEnvironments < ActiveRecord::Migration[4.2]
|
|
2
2
|
def up
|
|
3
3
|
create_table :environments do |t|
|
|
4
4
|
t.string :name, null: false, limit: 255
|
|
5
5
|
t.timestamps null: true
|
|
6
6
|
end
|
|
7
7
|
create_table :environments_puppetclasses do |t|
|
|
8
|
-
t.references :puppetclass,
|
|
8
|
+
t.references :puppetclass, null: false
|
|
9
9
|
t.references :environment, foreign_key: true
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def down
|
|
14
|
-
drop_table :environments
|
|
15
14
|
drop_table :environments_puppetclasses
|
|
15
|
+
drop_table :environments
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class CreatePuppetclasses < ActiveRecord::Migration[4.2]
|
|
2
|
+
def up
|
|
3
|
+
create_table :puppetclasses do |t|
|
|
4
|
+
t.string :name, limit: 255
|
|
5
|
+
t.string :nameindicator, limit: 255
|
|
6
|
+
t.integer :operatingsystem_id
|
|
7
|
+
|
|
8
|
+
t.timestamps null: true
|
|
9
|
+
end
|
|
10
|
+
add_foreign_key(:environments_puppetclasses, :puppetclasses)
|
|
11
|
+
|
|
12
|
+
create_table :hosts_puppetclasses, id: false do |t|
|
|
13
|
+
t.references :puppetclass, null: false
|
|
14
|
+
t.references :host, null: false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
create_table :operatingsystems_puppetclasses, id: false do |t|
|
|
18
|
+
t.references :puppetclass, null: false
|
|
19
|
+
t.references :operatingsystem, null: false
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def down
|
|
24
|
+
drop_table :operatingsystems_puppetclasses
|
|
25
|
+
drop_table :hosts_puppetclasses
|
|
26
|
+
remove_foreign_key(:environments_puppetclasses, :puppetclasses)
|
|
27
|
+
drop_table :puppetclasses
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateHostgroupsPuppetclasses < ActiveRecord::Migration[6.0]
|
|
2
|
+
def up
|
|
3
|
+
# this table is later renamed into hostgroup_classes and thus we don't want to create it if it exists under the later name
|
|
4
|
+
return if table_exists?(:hostgroups_puppetclasses) || table_exists?(:hostgroup_classes)
|
|
5
|
+
create_table :hostgroups_puppetclasses, id: false do |t|
|
|
6
|
+
t.references :hostgroup, foreign_key: true, null: false
|
|
7
|
+
t.references :puppetclass, foreign_key: true, null: false
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def down
|
|
12
|
+
drop_table :hostgroups_puppetclasses
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class CreateHostClass < ActiveRecord::Migration[4.2]
|
|
2
|
+
def up
|
|
3
|
+
rename_table :hosts_puppetclasses, :host_classes
|
|
4
|
+
add_column :host_classes, :id, :primary_key
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def down
|
|
8
|
+
remove_column :host_classes, :id
|
|
9
|
+
rename_table :host_classes, :hosts_puppetclasses
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
class AddSomeIndexes < ActiveRecord::Migration[4.2]
|
|
2
|
+
def up
|
|
3
|
+
# puppetclasses
|
|
4
|
+
add_index :puppetclasses, :name
|
|
5
|
+
|
|
6
|
+
# turn off Foreign Key checks
|
|
7
|
+
execute 'SET CONSTRAINTS ALL DEFERRED;' if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
|
|
8
|
+
|
|
9
|
+
add_foreign_key 'host_classes', 'hosts', name: 'host_classes_host_id_fk'
|
|
10
|
+
add_foreign_key 'host_classes', 'puppetclasses', name: 'host_classes_puppetclass_id_fk'
|
|
11
|
+
add_foreign_key 'operatingsystems_puppetclasses', 'operatingsystems', name: 'operatingsystems_puppetclasses_operatingsystem_id_fk'
|
|
12
|
+
add_foreign_key 'operatingsystems_puppetclasses', 'puppetclasses', name: 'operatingsystems_puppetclasses_puppetclass_id_fk'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def down
|
|
16
|
+
remove_foreign_key('host_classes', 'hosts') if foreign_key_exists?(:host_classes, :hosts)
|
|
17
|
+
remove_foreign_key('host_classes', 'puppetclasses') if foreign_key_exists?(:host_classes, :puppetclasses)
|
|
18
|
+
remove_foreign_key('operatingsystems_puppetclasses', 'operatingsystems') if foreign_key_exists?(:operatingsystems_puppetclasses, :operatingsystems)
|
|
19
|
+
remove_foreign_key('operatingsystems_puppetclasses', 'puppetclasses') if foreign_key_exists?(:operatingsystems_puppetclasses, :puppetclasses)
|
|
20
|
+
end
|
|
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
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
class CreateHostgroupClasses < ActiveRecord::Migration[4.2]
|
|
2
|
+
def up
|
|
3
|
+
rename_table :hostgroups_puppetclasses, :hostgroup_classes
|
|
4
|
+
add_column :hostgroup_classes, :id, :primary_key
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def down
|
|
8
|
+
remove_column :hostgroup_classes, :id
|
|
9
|
+
rename_table :hostgroup_classes, :hostgroups_puppetclasses
|
|
10
|
+
end
|
|
11
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ class DeleteOrphanedSmartClassParameters < ActiveRecord::Migration[4.2]
|
|
|
2
2
|
def up
|
|
3
3
|
condition = 'NOT EXISTS (SELECT 1 FROM environment_classes WHERE environment_classes.puppetclass_lookup_key_id = lookup_keys.id)'
|
|
4
4
|
LookupValue.joins(:lookup_key).where(condition).where("lookup_keys.type = 'PuppetclassLookupKey'").delete_all
|
|
5
|
-
|
|
5
|
+
LookupKey.where(condition).where(type: 'PuppetclassLookupKey').delete_all
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def down
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class AddUniquenessToPuppetclassName < ActiveRecord::Migration[5.1]
|
|
2
|
+
class FakePuppetclass < ApplicationRecord
|
|
3
|
+
self.table_name = 'puppetclasses'
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def up
|
|
7
|
+
names = FakePuppetclass.group(:name).count.select { |_key, value| value > 1 }.keys
|
|
8
|
+
unless names.empty?
|
|
9
|
+
names.each do |name|
|
|
10
|
+
classes = FakePuppetclass.where name: name
|
|
11
|
+
say "#{classes.count} Puppet classes with duplicate name detected: #{name}"
|
|
12
|
+
end
|
|
13
|
+
raise 'Please make sure there are no duplicate Puppet classes before continuing.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
remove_index :puppetclasses, :name
|
|
17
|
+
add_index :puppetclasses, :name, unique: true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def down
|
|
21
|
+
remove_index :puppetclasses, :name
|
|
22
|
+
add_index :puppetclasses, :name
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
class AddEnvironmentPuppetclassId < ActiveRecord::Migration[5.2]
|
|
3
3
|
def change
|
|
4
4
|
add_index :environment_classes, %i[environment_id puppetclass_id]
|
|
5
|
-
remove_index :environment_classes, :environment_id
|
|
5
|
+
remove_index(:environment_classes, :environment_id) if index_exists?(:environment_classes, :environment_id)
|
|
6
6
|
end
|
|
7
7
|
end
|
|
File without changes
|
|
@@ -1,38 +1,9 @@
|
|
|
1
1
|
module ForemanPuppet
|
|
2
2
|
class Engine < ::Rails::Engine
|
|
3
|
-
config.before_configuration do
|
|
4
|
-
unless ForemanPuppet.extracted_from_core?
|
|
5
|
-
require 'graphql'
|
|
6
|
-
|
|
7
|
-
module BaseObjectClassMethodPath
|
|
8
|
-
def field(*args, **kwargs, &block)
|
|
9
|
-
return if args.first == :environment && args.second.to_s == 'Types::Environment'
|
|
10
|
-
return if args.first == :environments && args.second.node_type.to_s == 'Types::Environment'
|
|
11
|
-
return if args.first == :puppetclass && args.second.to_s == 'Types::Puppetclass'
|
|
12
|
-
return if args.first == :puppetclasses && args.second.node_type.to_s == 'Types::Puppetclass'
|
|
13
|
-
|
|
14
|
-
super
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
module RelayClassicMutationClassMethodPath
|
|
19
|
-
# rubocop:disable Metrics/ParameterLists
|
|
20
|
-
def argument(name, type, *rest, loads: nil, **kwargs, &block)
|
|
21
|
-
# rubocop:enable Metrics/ParameterLists
|
|
22
|
-
return if [::Types::Environment, ::Types::Puppetclass].include?(loads)
|
|
23
|
-
|
|
24
|
-
super
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
GraphQL::Types::Relay::BaseObject.extend(BaseObjectClassMethodPath)
|
|
29
|
-
GraphQL::Schema::RelayClassicMutation.extend(RelayClassicMutationClassMethodPath)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
3
|
engine_name 'foreman_puppet'
|
|
34
4
|
isolate_namespace ForemanPuppet
|
|
35
5
|
|
|
6
|
+
config.paths['db/migrate'] << 'db/migrate_foreman' if Gem::Dependency.new('', ">= #{ForemanPuppet::FOREMAN_DROP_MIGRATIONS_VERSION}").match?('', SETTINGS[:version].notag)
|
|
36
7
|
config.paths['config/routes.rb'].unshift('config/api_routes.rb')
|
|
37
8
|
|
|
38
9
|
initializer 'foreman_puppet.register_plugin', before: :finisher_hook do |_app|
|
|
@@ -95,15 +66,12 @@ module ForemanPuppet
|
|
|
95
66
|
|
|
96
67
|
::SmartProxiesHelper::TABBED_FEATURES << 'Puppet'
|
|
97
68
|
|
|
98
|
-
unless ForemanPuppet.extracted_from_core?
|
|
99
|
-
::HostInfo.local_entries.delete('HostInfoProviders::PuppetInfo'.safe_constantize)
|
|
100
|
-
::HostInfo.local_entries.delete('HostInfoProviders::ConfigGroupsInfo'.safe_constantize)
|
|
101
|
-
::ProxyStatus.status_registry.delete('ProxyStatus::Puppet'.safe_constantize)
|
|
102
|
-
Foreman.input_types_registry.input_types.delete('puppet_parameter')
|
|
103
|
-
end
|
|
104
69
|
Foreman.input_types_registry.register(ForemanPuppet::InputType::PuppetParameterInput)
|
|
105
70
|
::ProxyStatus.status_registry.add(ForemanPuppet::ProxyStatus::Puppet)
|
|
106
71
|
|
|
72
|
+
# Extend smart_proxies API functionality
|
|
73
|
+
::Api::V2::SmartProxiesController.include ForemanPuppet::Extensions::ApiSmartProxiesController
|
|
74
|
+
|
|
107
75
|
# GraphQL
|
|
108
76
|
::Types::Host.include(ForemanPuppet::Types::HostExtensions)
|
|
109
77
|
::Types::Hostgroup.include(ForemanPuppet::Types::HostgroupExtensions)
|
|
@@ -1,34 +1,50 @@
|
|
|
1
1
|
Foreman::Plugin.register :foreman_puppet do
|
|
2
|
-
requires_foreman '>=
|
|
2
|
+
requires_foreman '>= 3.0.0'
|
|
3
3
|
# Add Global JS file for extending foreman-core components and routes
|
|
4
4
|
register_global_js_file 'fills'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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'))
|
|
17
25
|
end
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
23
39
|
end
|
|
24
40
|
|
|
41
|
+
apipie_documented_controllers(["#{ForemanPuppet::Engine.root}/app/controllers/foreman_puppet/api/v2/*.rb"])
|
|
42
|
+
|
|
25
43
|
# TODO: maybe this would not be necessary if we rething the form
|
|
26
44
|
%i[create_hostgroups edit_hostgroups].each do |perm|
|
|
27
45
|
p = Foreman::AccessControl.permission(perm)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
p.actions << 'hostgroups/puppetclass_parameters'
|
|
31
|
-
end
|
|
46
|
+
p.actions << 'hostgroups/environment_selected'
|
|
47
|
+
p.actions << 'hostgroups/puppetclass_parameters'
|
|
32
48
|
p.actions << 'foreman_puppet/puppetclasses/parameters'
|
|
33
49
|
end
|
|
34
50
|
p = Foreman::AccessControl.permission(:edit_hostgroups)
|
|
@@ -37,15 +53,13 @@ Foreman::Plugin.register :foreman_puppet do
|
|
|
37
53
|
end
|
|
38
54
|
%i[create_hosts edit_hosts].each do |perm|
|
|
39
55
|
p = Foreman::AccessControl.permission(perm)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
p.actions << 'hosts/update_multiple_puppet_proxy'
|
|
48
|
-
end
|
|
56
|
+
p.actions << 'hosts/hostgroup_or_environment_selected'
|
|
57
|
+
p.actions << 'hosts/puppetclass_parameters'
|
|
58
|
+
if perm == :edit_hosts
|
|
59
|
+
p.actions << 'hosts/select_multiple_environment'
|
|
60
|
+
p.actions << 'hosts/update_multiple_environment'
|
|
61
|
+
p.actions << 'hosts/select_multiple_puppet_proxy'
|
|
62
|
+
p.actions << 'hosts/update_multiple_puppet_proxy'
|
|
49
63
|
end
|
|
50
64
|
p.actions << 'foreman_puppet/puppetclasses/parameters'
|
|
51
65
|
end
|
|
@@ -133,7 +147,8 @@ Foreman::Plugin.register :foreman_puppet do
|
|
|
133
147
|
permission :import_puppetclasses, { 'foreman_puppet/puppetclasses' => %i[import_environments obsolete_and_new],
|
|
134
148
|
'foreman_puppet/api/v2/environments' => [:import_puppetclasses] },
|
|
135
149
|
resource_type: 'ForemanPuppet::Puppetclass'
|
|
136
|
-
permission :edit_classes, {
|
|
150
|
+
permission :edit_classes, { :host_editing => [:edit_classes],
|
|
151
|
+
'foreman_puppet/api/v2/host_classes' => %i[index create destroy] },
|
|
137
152
|
resource_type: 'ForemanPuppet::HostClass'
|
|
138
153
|
end
|
|
139
154
|
|
|
@@ -168,13 +183,13 @@ Foreman::Plugin.register :foreman_puppet do
|
|
|
168
183
|
register_facet ForemanPuppet::HostPuppetFacet, :puppet do
|
|
169
184
|
configure_host do
|
|
170
185
|
# extend_model ForemanPuppet::Extensions::Host
|
|
171
|
-
api_view list: 'foreman_puppet/api/v2/host_puppet_facets/
|
|
186
|
+
api_view list: 'foreman_puppet/api/v2/host_puppet_facets/host_list',
|
|
172
187
|
single: 'foreman_puppet/api/v2/host_puppet_facets/host_single'
|
|
173
188
|
template_compatibility_properties :environment, :environment_id, :environment_name
|
|
174
189
|
set_dependent_action :destroy
|
|
175
190
|
end
|
|
176
191
|
configure_hostgroup(ForemanPuppet::HostgroupPuppetFacet) do
|
|
177
|
-
api_view list: 'foreman_puppet/api/v2/hostgroup_puppet_facets/
|
|
192
|
+
api_view list: 'foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_list',
|
|
178
193
|
single: 'foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single'
|
|
179
194
|
template_compatibility_properties :environment, :environment_id, :environment_name
|
|
180
195
|
set_dependent_action :destroy
|
|
@@ -185,14 +200,6 @@ Foreman::Plugin.register :foreman_puppet do
|
|
|
185
200
|
base_scope.preload(puppet: :environment)
|
|
186
201
|
end
|
|
187
202
|
|
|
188
|
-
unless ForemanPuppet.extracted_from_core?
|
|
189
|
-
Rails.application.config.after_initialize do
|
|
190
|
-
list = Pagelets::Manager.instance.instance_variable_get(:@pagelets)['hosts/_form'][:main_tabs]
|
|
191
|
-
core_pagelet = list.detect { |pagelet| pagelet.opts[:id] == :puppet_klasses }
|
|
192
|
-
list.delete(core_pagelet)
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
203
|
register_graphql_query_field :environment, 'ForemanPuppet::Types::Environment', :record_field
|
|
197
204
|
register_graphql_query_field :environments, 'ForemanPuppet::Types::Environment', :collection_field
|
|
198
205
|
register_graphql_query_field :puppetclass, 'ForemanPuppet::Types::Puppetclass', :record_field
|
|
@@ -212,12 +219,10 @@ Foreman::Plugin.register :foreman_puppet do
|
|
|
212
219
|
priority: 100,
|
|
213
220
|
onlyif: (host_onlyif if resource_type == :host)
|
|
214
221
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
priority: 100
|
|
220
|
-
end
|
|
222
|
+
context.add_pagelet :main_tab_fields,
|
|
223
|
+
partial: 'hosts/foreman_puppet/form_main_tab_fields',
|
|
224
|
+
resource_type: resource_type,
|
|
225
|
+
priority: 100
|
|
221
226
|
end
|
|
222
227
|
end
|
|
223
228
|
end
|
data/lib/foreman_puppet.rb
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
module ForemanPuppet
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def self.extracted_from_core?
|
|
5
|
-
ENV['PUPPET_EXTRACTED'].to_s == '1' ||
|
|
6
|
-
Gem::Dependency.new('', ">= #{FOREMAN_EXTRACTION_VERSION}").match?('', SETTINGS[:version].notag)
|
|
7
|
-
end
|
|
2
|
+
FOREMAN_DROP_MIGRATIONS_VERSION = '3.1'.freeze
|
|
8
3
|
end
|
|
9
4
|
|
|
10
5
|
require 'foreman_puppet/engine'
|
|
Binary file
|