foreman_puppet 0.0.1 → 1.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -7
- data/app/controllers/concerns/foreman_puppet/environments_import.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_base_controller.rb +28 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +1 -1
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +3 -10
- data/app/controllers/concerns/foreman_puppet/parameters/puppetclass_lookup_key.rb +2 -2
- data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +5 -2
- data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +9 -1
- data/app/controllers/foreman_puppet/api/v2/override_values_controller.rb +1 -2
- data/app/controllers/foreman_puppet/api/v2/{base_controller.rb → puppet_base_controller.rb} +2 -3
- data/app/controllers/foreman_puppet/api/v2/{lookups_common_controller.rb → puppet_lookups_common_controller.rb} +6 -2
- data/app/controllers/foreman_puppet/api/v2/puppetclasses_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb +1 -2
- data/app/controllers/foreman_puppet/config_groups_controller.rb +4 -0
- data/app/controllers/foreman_puppet/puppet_smart_proxies_controller.rb +4 -0
- data/app/controllers/foreman_puppet/puppetclass_lookup_keys_controller.rb +2 -2
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +12 -4
- data/app/graphgl/concerns/foreman_puppet/mutations/hosts/create_extensions.rb +29 -0
- data/app/graphgl/concerns/foreman_puppet/types/host_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/hostgroup_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/interface_attributes_input_extensions.rb +9 -0
- data/app/graphgl/concerns/foreman_puppet/types/location_extensions.rb +14 -0
- data/app/graphgl/concerns/foreman_puppet/types/organization_extensions.rb +14 -0
- data/app/graphgl/foreman_puppet/types/environment.rb +20 -0
- data/app/graphgl/foreman_puppet/types/puppetclass.rb +20 -0
- data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/hosts_helper.rb +15 -0
- data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +2 -2
- data/app/helpers/foreman_puppet/puppetclasses_and_environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/puppetclasses_helper.rb +2 -2
- data/app/models/concerns/foreman_puppet/extensions/host.rb +24 -9
- data/app/models/concerns/foreman_puppet/extensions/host_common.rb +17 -0
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +13 -7
- data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +19 -13
- data/app/models/concerns/foreman_puppet/extensions/report.rb +18 -0
- data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/user.rb +19 -12
- data/app/models/foreman_puppet/environment.rb +2 -0
- data/app/models/foreman_puppet/environment_class.rb +1 -1
- data/app/models/foreman_puppet/host_class.rb +1 -1
- data/app/models/foreman_puppet/host_puppet_facet.rb +5 -4
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +1 -1
- data/app/models/{concerns/foreman_puppet/host_common.rb → foreman_puppet/puppet_facet_common.rb} +1 -1
- data/app/models/foreman_puppet/puppetclass.rb +15 -1
- data/app/{views/api/v2/template_combinations/base.json.erb → prepend_views/api/v2/template_combinations/base.json.rabl} +0 -0
- data/app/services/foreman_puppet/host_info_providers/config_groups_info.rb +2 -0
- data/app/services/foreman_puppet/puppet_class_importer.rb +17 -18
- data/app/views/foreman_puppet/common/_puppetclasses_or_envs_changed.html.erb +62 -0
- data/app/views/foreman_puppet/config_groups/index.html.erb +2 -2
- data/app/views/foreman_puppet/config_groups/welcome.html.erb +12 -11
- data/app/views/foreman_puppet/environments/index.html.erb +1 -1
- data/app/views/foreman_puppet/environments/welcome.html.erb +3 -15
- data/app/views/foreman_puppet/puppetclass_lookup_keys/welcome.html.erb +10 -8
- data/app/views/foreman_puppet/puppetclasses/_classes.html.erb +1 -1
- data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +1 -1
- data/app/views/foreman_puppet/puppetclasses/index.html.erb +1 -1
- data/app/views/hosts/_form_puppet_enc_tab.html.erb +1 -1
- data/app/views/hosts/select_multiple_environment.html.erb +1 -1
- data/app/views/smart_proxies/plugins/_puppet_ca.html.erb +44 -0
- data/config/initializers/api_reroute.rb +13 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +37 -12
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +13 -1
- data/lib/foreman_puppet.rb +3 -3
- data/lib/foreman_puppet/engine.rb +68 -19
- data/lib/foreman_puppet/register.rb +7 -2
- data/lib/foreman_puppet/version.rb +1 -1
- data/locale/Makefile +1 -1
- data/locale/action_names.rb +4 -4
- data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en/foreman_puppet.edit.po +19 -3
- data/locale/en/foreman_puppet.po +18 -6
- data/locale/en/foreman_puppet.pox +0 -0
- data/locale/foreman_puppet.pot +19 -3
- data/locale/messages.mo +0 -0
- data/package.json +45 -0
- data/test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +18 -16
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +3 -2
- data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/api/v2/provisioning_templates_controller_test.rb +32 -0
- data/test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb +3 -0
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +7 -1
- data/test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/environments_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/puppetclasses_controller_test.rb +5 -6
- data/test/factories/foreman_puppet_factories.rb +3 -0
- data/test/factories/host_puppet_enhancements.rb +6 -6
- data/test/graphql/mutations/hosts/create_mutation_test.rb +87 -0
- data/test/graphql/queries/environment_query_test.rb +54 -0
- data/test/graphql/queries/environments_query_test.rb +43 -0
- data/test/{qraphql → graphql}/queries/host_puppet_query_test.rb +3 -8
- data/test/{qraphql → graphql}/queries/hostgroup_puppet_query_test.rb +1 -6
- data/test/graphql/queries/location_query_test.rb +52 -0
- data/test/graphql/queries/organization_query_test.rb +52 -0
- data/test/graphql/queries/puppetclass_query_test.rb +68 -0
- data/test/graphql/queries/puppetclasses_query_test.rb +43 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +4 -1
- data/test/integration/foreman_puppet/host_js_test.rb +1 -1
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +4 -0
- data/test/models/foreman_puppet/config_group_class_test.rb +3 -1
- data/test/models/foreman_puppet/environment_test.rb +2 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +34 -1
- data/test/models/foreman_puppet/host_test.rb +4 -3
- data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +2 -3
- data/test/models/foreman_puppet/provisioning_template_test.rb +14 -7
- data/test/models/foreman_puppet/report_test.rb +21 -0
- data/test/models/foreman_puppet/smart_proxy_test.rb +1 -1
- data/test/models/foreman_puppet/user_test.rb +37 -0
- data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +35 -0
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +159 -197
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +16 -2
- data/webpack/index.js +3 -4
- data/webpack/src/Components/Environments/Welcome.js +37 -0
- metadata +54 -14
@@ -3,6 +3,6 @@
|
|
3
3
|
<%= form_for :environment, url: foreman_puppet.update_multiple_environment_hosts_path(host_ids: params[:host_ids]) do |f| %>
|
4
4
|
<%= selectable_f f, :id, [[_('Select environment'), 'disabled'],
|
5
5
|
[_('*Clear environment*'), '' ],
|
6
|
-
[_('*Inherit from host group*'), 'inherit']] + Environment.all.map{|e| [e.name, e.id]}, {},
|
6
|
+
[_('*Inherit from host group*'), 'inherit']] + ForemanPuppet::Environment.all.map{|e| [e.name, e.id]}, {},
|
7
7
|
label: _('Environment'), onchange: 'tfm.hosts.table.toggleMultipleOkButton(this)' %>
|
8
8
|
<% end %>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<ul id="proxy-puppetca-tab" class="nav nav-tabs nav-tabs-pf">
|
2
|
+
<li class="active"><a href="#ca_general" data-toggle="tab"><%= _("General") %></a></li>
|
3
|
+
<% if authorized_for(:permission => :view_smart_proxies_puppetca, :auth_object => @smart_proxy, :authorizer => authorizer) %>
|
4
|
+
<li><a href="#certificates" data-toggle="tab"><%= _("Certificates") %></a></li>
|
5
|
+
<% end %>
|
6
|
+
<% if authorized_for(:permission => :view_smart_proxies_autosign, :auth_object => @smart_proxy, :authorizer => authorizer) %>
|
7
|
+
<li><a href="#autosign" data-toggle="tab"><%= _("Autosign entries") %></a></li>
|
8
|
+
<% end %>
|
9
|
+
</ul>
|
10
|
+
<div id="proxy-puppetca-tab-content" class="tab-content">
|
11
|
+
<div class="tab-pane active in" id="ca_general">
|
12
|
+
<div class="row">
|
13
|
+
<div class="col-md-6">
|
14
|
+
<%= show_feature_version('puppetca') %>
|
15
|
+
<div class="row">
|
16
|
+
<div class="col-md-4"><strong><%= _('Hosts managed:') %></strong></div>
|
17
|
+
<div class="col-md-8">
|
18
|
+
<%= link_to Host::Managed.where(:puppet_ca_proxy_id => @smart_proxy.id).count, hosts_path(:search => "puppet_ca = \"#{@smart_proxy.name}\"") %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
<div class="container-fluid container-cards-pf">
|
24
|
+
<div class="row row-cards-pf">
|
25
|
+
<% if authorized_for(:permission => :view_smart_proxies_puppetca, :auth_object => @smart_proxy) %>
|
26
|
+
<span data-ajax-url="<%= counts_smart_proxy_puppetca_path(:smart_proxy_id => @smart_proxy) %>"><%= spinner%></span>
|
27
|
+
<span data-ajax-url="<%= expiry_smart_proxy_puppetca_path(:smart_proxy_id => @smart_proxy) %>"><%= spinner%></span>
|
28
|
+
<% end %>
|
29
|
+
<% if authorized_for(:permission => :view_smart_proxies_autosign, :auth_object => @smart_proxy, :authorizer => authorizer) %>
|
30
|
+
<span data-ajax-url="<%= counts_smart_proxy_autosign_path(:smart_proxy_id => @smart_proxy) %>"><%= spinner%></span>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<% if authorized_for(:permission => :view_smart_proxies_puppetca, :auth_object => @smart_proxy, :authorizer => authorizer) %>
|
36
|
+
<div class="tab-pane" id="certificates" data-ajax-url="<%= smart_proxy_puppetca_index_path(:smart_proxy_id => @smart_proxy) %>" data-on-complete="certTable"><%= spinner %></div>
|
37
|
+
<% end %>
|
38
|
+
<% if authorized_for(:permission => :view_smart_proxies_autosign, :auth_object => @smart_proxy, :authorizer => authorizer) %>
|
39
|
+
<div class="tab-pane" id="autosign" data-ajax-url="<%= smart_proxy_autosign_index_path(:smart_proxy_id => @smart_proxy) %>" data-on-complete="tfm.tools.activateDatatables"><%= spinner %></div>
|
40
|
+
<% if authorized_for(:permission => :create_smart_proxies_autosign, :auth_object => @smart_proxy, :authorizer => authorizer) %>
|
41
|
+
<div data-ajax-url=<%= new_smart_proxy_autosign_path(:smart_proxy_id => @smart_proxy) %>></div>
|
42
|
+
<% end %>
|
43
|
+
<% end %>
|
44
|
+
</div>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Foreman::Application.routes.prepend do
|
2
|
+
namespace :api, defaults: { format: 'json' } do
|
3
|
+
scope '(:apiv)', module: :v2, defaults: { apiv: 'v2' }, apiv: /v2/, constraints: ApiConstraints.new(version: 2, default: true) do
|
4
|
+
resources :puppetclasses, controller: '/foreman_puppet/api/v2/puppetclasses', except: %i[new edit]
|
5
|
+
resources :environments, controller: '/foreman_puppet/api/v2/environments', except: %i[new edit]
|
6
|
+
resources :hosts, controller: '/foreman_puppet/api/v2/hosts', only: []
|
7
|
+
resources :hostgroups, controller: '/foreman_puppet/api/v2/hostgroups', only: %i[]
|
8
|
+
resources :config_groups, controller: '/foreman_puppet/api/v2/config_groups', except: %i[new edit]
|
9
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit]
|
10
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -1,29 +1,54 @@
|
|
1
1
|
class MigrateHostTypeInHostConfigGroups < ActiveRecord::Migration[6.0]
|
2
|
+
class FakeHostConfigGroup < ::ApplicationRecord
|
3
|
+
self.table_name = 'host_config_groups'
|
4
|
+
|
5
|
+
scope :for_host, -> { where(host_type: %w[Host::Base Host::Managed]) }
|
6
|
+
scope :for_hostgroup, -> { where(host_type: 'Hostgroup') }
|
7
|
+
scope :for_host_facet, -> { where(host_type: 'ForemanPuppet::HostPuppetFacet') }
|
8
|
+
scope :for_hostgroup_facet, -> { where(host_type: 'ForemanPuppet::HostgroupPuppetFacet') }
|
9
|
+
end
|
10
|
+
|
11
|
+
class FakeConfigGroup < ::ApplicationRecord
|
12
|
+
self.table_name = 'config_groups'
|
13
|
+
end
|
14
|
+
|
2
15
|
def up
|
3
|
-
host_config_group_ids =
|
16
|
+
host_config_group_ids = FakeHostConfigGroup.for_host.pluck(:host_id).uniq
|
4
17
|
host_config_group_ids.each do |host_id|
|
5
18
|
host_facet_id = ForemanPuppet::HostPuppetFacet.where(host_id: host_id).pick(:id)
|
6
|
-
|
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
|
7
27
|
end
|
8
|
-
hostgroup_config_group_ids =
|
28
|
+
hostgroup_config_group_ids = FakeHostConfigGroup.for_hostgroup.pluck(:host_id).uniq
|
9
29
|
hostgroup_config_group_ids.each do |hostgroup_id|
|
10
30
|
hostgroup_facet_id = ForemanPuppet::HostgroupPuppetFacet.where(hostgroup_id: hostgroup_id).pick(:id)
|
11
|
-
|
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)
|
12
35
|
end
|
13
36
|
end
|
14
37
|
|
15
38
|
def down
|
16
|
-
host_config_group_ids =
|
17
|
-
host_facet_ids =
|
39
|
+
host_config_group_ids = FakeHostConfigGroup.for_host_facet.pluck(:host_id).uniq
|
40
|
+
host_facet_ids = ForemanPuppet::HostPuppetFacet.where(id: host_config_group_ids).pluck(:id, :host_id).to_h
|
18
41
|
host_config_group_ids.each do |host_puppet_facet_id|
|
19
|
-
|
20
|
-
|
42
|
+
FakeHostConfigGroup.for_host_facet
|
43
|
+
.where(host_id: host_puppet_facet_id)
|
44
|
+
.update_all(host_type: 'Host::Managed', host_id: host_facet_ids[host_puppet_facet_id])
|
21
45
|
end
|
22
|
-
hostgroup_config_group_ids =
|
23
|
-
hostgroup_facet_ids =
|
46
|
+
hostgroup_config_group_ids = FakeHostConfigGroup.for_hostgroup_facet.pluck(:host_id).uniq
|
47
|
+
hostgroup_facet_ids = ForemanPuppet::HostgroupPuppetFacet.where(id: hostgroup_config_group_ids).pluck(:id, :hostgroup_id).to_h
|
24
48
|
hostgroup_config_group_ids.each do |hostgroup_facet_id|
|
25
|
-
|
26
|
-
|
49
|
+
FakeHostConfigGroup.for_hostgroup_facet
|
50
|
+
.where(host_id: hostgroup_facet_id)
|
51
|
+
.update_all(host_type: 'Hostgroup', host_id: hostgroup_facet_ids[hostgroup_facet_id])
|
27
52
|
end
|
28
53
|
end
|
29
54
|
end
|
@@ -7,6 +7,10 @@ class MigratePuppetclassesToFacets < ActiveRecord::Migration[6.0]
|
|
7
7
|
self.table_name = 'hostgroup_classes'
|
8
8
|
end
|
9
9
|
|
10
|
+
class FakePuppetclass < ApplicationRecord
|
11
|
+
self.table_name = 'puppetclasses'
|
12
|
+
end
|
13
|
+
|
10
14
|
def up
|
11
15
|
add_reference :host_classes, :host_puppet_facet, foreign_key: true, index: true
|
12
16
|
add_reference :hostgroup_classes, :hostgroup_puppet_facet, foreign_key: true, index: true
|
@@ -14,11 +18,19 @@ class MigratePuppetclassesToFacets < ActiveRecord::Migration[6.0]
|
|
14
18
|
host_ids = FakeHostClass.all.pluck(:host_id).uniq
|
15
19
|
host_ids.each do |host_id|
|
16
20
|
host_facet = ForemanPuppet::HostPuppetFacet.find_by(host_id: host_id)
|
17
|
-
ForemanPuppet::HostClass.where(host_id: host_id)
|
21
|
+
host_classes = ForemanPuppet::HostClass.where(host_id: host_id)
|
22
|
+
if host_facet
|
23
|
+
host_classes.update_all(host_puppet_facet_id: host_facet.id)
|
24
|
+
else
|
25
|
+
deleted_classes = FakePuppetclass.where(id: host_classes.pluck(:puppetclass_id)).pluck(:name)
|
26
|
+
say "deleting classes #{deleted_classes.join(', ')} from Host (id=#{host_id}) because it has no environment"
|
27
|
+
host_classes.delete_all
|
28
|
+
end
|
18
29
|
end
|
19
30
|
hostgroup_ids = FakeHostgroupClass.all.pluck(:hostgroup_id).uniq
|
20
31
|
hostgroup_ids.each do |hostgroup_id|
|
21
32
|
hostgroup_facet = ForemanPuppet::HostgroupPuppetFacet.find_by(hostgroup_id: hostgroup_id)
|
33
|
+
hostgroup_facet ||= ForemanPuppet::HostgroupPuppetFacet.create(hostgroup: Hostgroup.unscoped.find(hostgroup_id))
|
22
34
|
ForemanPuppet::HostgroupClass.where(hostgroup_id: hostgroup_id).update_all(hostgroup_puppet_facet_id: hostgroup_facet.id)
|
23
35
|
end
|
24
36
|
|
data/lib/foreman_puppet.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module ForemanPuppet
|
2
|
-
FOREMAN_EXTRACTION_VERSION = '
|
2
|
+
FOREMAN_EXTRACTION_VERSION = '3.0'.freeze
|
3
3
|
|
4
4
|
def self.extracted_from_core?
|
5
|
-
ENV['PUPPET_EXTRACTED'] == '1' ||
|
6
|
-
Gem::Dependency.new('', ">= #{FOREMAN_EXTRACTION_VERSION}").match?('', SETTINGS[:version])
|
5
|
+
ENV['PUPPET_EXTRACTED'].to_s == '1' ||
|
6
|
+
Gem::Dependency.new('', ">= #{FOREMAN_EXTRACTION_VERSION}").match?('', SETTINGS[:version].notag)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -1,5 +1,35 @@
|
|
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
|
+
|
3
33
|
engine_name 'foreman_puppet'
|
4
34
|
isolate_namespace ForemanPuppet
|
5
35
|
|
@@ -19,43 +49,50 @@ module ForemanPuppet
|
|
19
49
|
end
|
20
50
|
end
|
21
51
|
|
22
|
-
initializer '
|
52
|
+
initializer 'foreman_puppet.configure_assets', group: :assets do
|
23
53
|
SETTINGS[:foreman_puppet] = { assets: { precompile: ['foreman_puppet.scss'] } }
|
24
54
|
end
|
25
55
|
|
26
|
-
|
27
|
-
config.to_prepare do
|
56
|
+
initializer 'foreman_puppet.patch_parameters' do
|
28
57
|
# Parameters should go ASAP as they need to be applied before they are included in core controller
|
29
|
-
Foreman::Controller::Parameters::Host.include ForemanPuppet::Extensions::ParametersHost
|
30
|
-
Foreman::Controller::Parameters::Hostgroup.include ForemanPuppet::Extensions::ParametersHostgroup
|
31
58
|
Foreman::Controller::Parameters::TemplateCombination.include ForemanPuppet::Extensions::ParametersTemplateCombination
|
59
|
+
end
|
32
60
|
|
61
|
+
# Include concerns in this config.to_prepare block
|
62
|
+
# rubocop:disable Metrics/BlockLength
|
63
|
+
config.to_prepare do
|
33
64
|
# Facets extenstion is applied too early - before the Hostgroup is complete
|
34
65
|
# We redefine thing, so we need to wait until complete definition of Hostgroup
|
35
66
|
# thus separate patching instead of using facet patching
|
36
|
-
Hostgroup.include ForemanPuppet::Extensions::Hostgroup
|
67
|
+
::Hostgroup.include ForemanPuppet::Extensions::Hostgroup
|
37
68
|
|
38
69
|
# include_in_clone that is used in core Facets::ManagedHostExtensions doesn't support nested objects
|
39
70
|
# we need to run our include_in_clone after, so the puppet without nested objects doesnt override the one including them
|
40
|
-
Host::Managed.include ForemanPuppet::Extensions::Host
|
71
|
+
::Host::Managed.include ForemanPuppet::Extensions::Host
|
41
72
|
|
42
|
-
LookupValue.include ForemanPuppet::PuppetLookupValueExtensions
|
43
|
-
Operatingsystem.include ForemanPuppet::Extensions::Operatingsystem
|
44
|
-
Nic::Managed.include ForemanPuppet::Extensions::NicManaged
|
45
|
-
Report.include ForemanPuppet::Extensions::Report
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
73
|
+
::LookupValue.include ForemanPuppet::PuppetLookupValueExtensions
|
74
|
+
::Operatingsystem.include ForemanPuppet::Extensions::Operatingsystem
|
75
|
+
::Nic::Managed.include ForemanPuppet::Extensions::NicManaged
|
76
|
+
::Report.include ForemanPuppet::Extensions::Report
|
77
|
+
::Location.include ForemanPuppet::Extensions::Taxonomy
|
78
|
+
::Organization.include ForemanPuppet::Extensions::Taxonomy
|
79
|
+
::User.include ForemanPuppet::Extensions::User
|
80
|
+
::TemplateCombination.include ForemanPuppet::Extensions::TemplateCombination
|
81
|
+
::ProvisioningTemplate.include ForemanPuppet::Extensions::ProvisioningTemplate
|
50
82
|
|
83
|
+
::Api::V2::BaseController.include ForemanPuppet::Extensions::ApiBaseController
|
51
84
|
::Api::V2::HostsController.include ForemanPuppet::Extensions::ApiV2HostsController
|
52
85
|
::Api::V2::HostgroupsController.include ForemanPuppet::Extensions::ApiHostgroupsController
|
53
86
|
::Api::V2::TemplateCombinationsController.include ForemanPuppet::Extensions::ApiTemplateCombinationsController
|
54
|
-
|
55
|
-
|
56
|
-
|
87
|
+
::Api::V2::HostsController.include ForemanPuppet::Extensions::ParametersHost
|
88
|
+
::Api::V2::HostgroupsController.include ForemanPuppet::Extensions::ParametersHostgroup
|
89
|
+
::OperatingsystemsController.prepend ForemanPuppet::Extensions::OperatingsystemsController
|
90
|
+
::HostsController.include ForemanPuppet::Extensions::HostsControllerExtensions
|
91
|
+
::HostsController.include ForemanPuppet::Extensions::ParametersHost
|
92
|
+
::HostgroupsController.include ForemanPuppet::Extensions::HostgroupsControllerExtensions
|
93
|
+
::HostgroupsController.include ForemanPuppet::Extensions::ParametersHostgroup
|
57
94
|
|
58
|
-
SmartProxiesHelper::TABBED_FEATURES << 'Puppet'
|
95
|
+
::SmartProxiesHelper::TABBED_FEATURES << 'Puppet'
|
59
96
|
|
60
97
|
unless ForemanPuppet.extracted_from_core?
|
61
98
|
::HostInfo.local_entries.delete('HostInfoProviders::PuppetInfo'.safe_constantize)
|
@@ -65,7 +102,19 @@ module ForemanPuppet
|
|
65
102
|
end
|
66
103
|
Foreman.input_types_registry.register(ForemanPuppet::InputType::PuppetParameterInput)
|
67
104
|
::ProxyStatus.status_registry.add(ForemanPuppet::ProxyStatus::Puppet)
|
105
|
+
|
106
|
+
# GraphQL
|
107
|
+
::Types::Host.include(ForemanPuppet::Types::HostExtensions)
|
108
|
+
::Types::Hostgroup.include(ForemanPuppet::Types::HostgroupExtensions)
|
109
|
+
::Types::Location.include(ForemanPuppet::Types::LocationExtensions)
|
110
|
+
::Types::Organization.include(ForemanPuppet::Types::OrganizationExtensions)
|
111
|
+
::Types::InterfaceAttributesInput.include(ForemanPuppet::Types::InterfaceAttributesInputExtensions)
|
112
|
+
|
113
|
+
::Mutations::Hosts::Create.include(ForemanPuppet::Mutations::Hosts::CreateExtensions)
|
114
|
+
rescue StandardError => e
|
115
|
+
Rails.logger.warn "ForemanPuppet: skipping engine hook (#{e})\n#{e.backtrace.join("\n")}"
|
68
116
|
end
|
117
|
+
# rubocop:enable Metrics/BlockLength
|
69
118
|
|
70
119
|
rake_tasks do
|
71
120
|
Rake::Task['db:seed'].enhance do
|
@@ -169,13 +169,13 @@ Foreman::Plugin.register :foreman_puppet do
|
|
169
169
|
configure_host do
|
170
170
|
# extend_model ForemanPuppet::Extensions::Host
|
171
171
|
api_view list: 'foreman_puppet/api/v2/host_puppet_facets/base',
|
172
|
-
|
172
|
+
single: 'foreman_puppet/api/v2/host_puppet_facets/host_single'
|
173
173
|
template_compatibility_properties :environment, :environment_id, :environment_name
|
174
174
|
set_dependent_action :destroy
|
175
175
|
end
|
176
176
|
configure_hostgroup(ForemanPuppet::HostgroupPuppetFacet) do
|
177
177
|
api_view list: 'foreman_puppet/api/v2/hostgroup_puppet_facets/base',
|
178
|
-
|
178
|
+
single: 'foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single'
|
179
179
|
template_compatibility_properties :environment, :environment_id, :environment_name
|
180
180
|
set_dependent_action :destroy
|
181
181
|
end
|
@@ -193,6 +193,11 @@ Foreman::Plugin.register :foreman_puppet do
|
|
193
193
|
end
|
194
194
|
end
|
195
195
|
|
196
|
+
register_graphql_query_field :environment, 'ForemanPuppet::Types::Environment', :record_field
|
197
|
+
register_graphql_query_field :environments, 'ForemanPuppet::Types::Environment', :collection_field
|
198
|
+
register_graphql_query_field :puppetclass, 'ForemanPuppet::Types::Puppetclass', :record_field
|
199
|
+
register_graphql_query_field :puppetclasses, 'ForemanPuppet::Types::Puppetclass', :collection_field
|
200
|
+
|
196
201
|
extend_template_helpers(ForemanPuppet::TemplateRendererScope)
|
197
202
|
|
198
203
|
# extend host(group) form with puppet ENC Tab
|
data/locale/Makefile
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# make tx-update - download and merge translations from Transifex
|
7
7
|
# make clean - clean everything
|
8
8
|
#
|
9
|
-
DOMAIN =
|
9
|
+
DOMAIN = foreman_puppet
|
10
10
|
VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
|
11
11
|
POTFILE = $(DOMAIN).pot
|
12
12
|
MOFILE = $(DOMAIN).mo
|
data/locale/action_names.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Autogenerated!
|
2
|
-
_(
|
3
|
-
_(
|
4
|
-
_(
|
5
|
-
_(
|
2
|
+
_('Action with sub plans')
|
3
|
+
_('Import facts')
|
4
|
+
_('Import Puppet classes')
|
5
|
+
_('Remote action:')
|
Binary file
|
@@ -4,9 +4,9 @@
|
|
4
4
|
#
|
5
5
|
msgid ""
|
6
6
|
msgstr ""
|
7
|
-
"Project-Id-Version:
|
7
|
+
"Project-Id-Version: foreman_puppet 0.0.2\n"
|
8
8
|
"Report-Msgid-Bugs-To: \n"
|
9
|
-
"POT-Creation-Date: 2021-02-
|
9
|
+
"POT-Creation-Date: 2021-02-03 18:00+0100\n"
|
10
10
|
"PO-Revision-Date: 2014-08-20 08:54+0100\n"
|
11
11
|
"Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
|
12
12
|
"Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
|
@@ -906,6 +906,22 @@ msgstr ""
|
|
906
906
|
msgid "Loading parameters..."
|
907
907
|
msgstr ""
|
908
908
|
|
909
|
+
#: action_names.rb:2
|
910
|
+
msgid "Action with sub plans"
|
911
|
+
msgstr ""
|
912
|
+
|
913
|
+
#: action_names.rb:3
|
914
|
+
msgid "Import facts"
|
915
|
+
msgstr ""
|
916
|
+
|
917
|
+
#: action_names.rb:4
|
918
|
+
msgid "Import Puppet classes"
|
919
|
+
msgstr ""
|
920
|
+
|
921
|
+
#: action_names.rb:5
|
922
|
+
msgid "Remote action:"
|
923
|
+
msgstr ""
|
924
|
+
|
909
925
|
#: gemspec.rb:2
|
910
|
-
msgid "
|
926
|
+
msgid "Allow assigning Puppet environmets and classes to the Foreman Hosts."
|
911
927
|
msgstr ""
|
data/locale/en/foreman_puppet.po
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# foreman_puppet
|
2
2
|
#
|
3
|
-
# This file is distributed under the same license as
|
3
|
+
# This file is distributed under the same license as foreman_puppet.
|
4
4
|
#
|
5
5
|
msgid ""
|
6
6
|
msgstr ""
|
7
|
-
"Project-Id-Version:
|
7
|
+
"Project-Id-Version: foreman_puppet 0.0.2\n"
|
8
8
|
"Report-Msgid-Bugs-To: \n"
|
9
9
|
"PO-Revision-Date: 2014-08-20 08:54+0100\n"
|
10
10
|
"Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
|
@@ -48,6 +48,9 @@ msgstr ""
|
|
48
48
|
msgid "A config group provides a one-step method of associating many Puppet classes to either a host or host group. Typically this would be used to add a particular application profile or stack in one step."
|
49
49
|
msgstr ""
|
50
50
|
|
51
|
+
msgid "Action with sub plans"
|
52
|
+
msgstr ""
|
53
|
+
|
51
54
|
msgid "Actions"
|
52
55
|
msgstr ""
|
53
56
|
|
@@ -66,6 +69,9 @@ msgstr ""
|
|
66
69
|
msgid "All environments - (not filtered)"
|
67
70
|
msgstr ""
|
68
71
|
|
72
|
+
msgid "Allow assigning Puppet environmets and classes to the Foreman Hosts."
|
73
|
+
msgstr ""
|
74
|
+
|
69
75
|
msgid "Available Classes"
|
70
76
|
msgstr ""
|
71
77
|
|
@@ -285,12 +291,18 @@ msgstr ""
|
|
285
291
|
msgid "Import"
|
286
292
|
msgstr ""
|
287
293
|
|
294
|
+
msgid "Import Puppet classes"
|
295
|
+
msgstr ""
|
296
|
+
|
288
297
|
msgid "Import classes from %s"
|
289
298
|
msgstr ""
|
290
299
|
|
291
300
|
msgid "Import environments from %s"
|
292
301
|
msgstr ""
|
293
302
|
|
303
|
+
msgid "Import facts"
|
304
|
+
msgstr ""
|
305
|
+
|
294
306
|
msgid "Import puppet classes from puppet proxy"
|
295
307
|
msgstr ""
|
296
308
|
|
@@ -510,6 +522,9 @@ msgstr ""
|
|
510
522
|
msgid "Puppetclass|Name"
|
511
523
|
msgstr ""
|
512
524
|
|
525
|
+
msgid "Remote action:"
|
526
|
+
msgstr ""
|
527
|
+
|
513
528
|
msgid "Remove"
|
514
529
|
msgstr ""
|
515
530
|
|
@@ -576,9 +591,6 @@ msgstr ""
|
|
576
591
|
msgid "Successfully updated environments and Puppet classes from the on-disk Puppet installation"
|
577
592
|
msgstr ""
|
578
593
|
|
579
|
-
msgid "TODO: Description of ForemanPuppetEnc."
|
580
|
-
msgstr ""
|
581
|
-
|
582
594
|
msgid "The %{proxy_type} proxy could not be set for host: %{host_names}."
|
583
595
|
msgid_plural "The %{proxy_type} puppet ca proxy could not be set for hosts: %{host_names}"
|
584
596
|
msgstr[0] ""
|