Skip to content

Commit

Permalink
Fixes #36207 - Setup puppet during Host Registration
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard authored and nadjaheitmann committed Jul 12, 2024
1 parent b706bfd commit 23b7d8a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module ForemanPuppet
module Extensions
module ApiV2RegistrationControllerExtensions
extend ActiveSupport::Concern

def host_setup_extension
if @host.hostgroup.present?
@host.puppet_proxy_id = @host.hostgroup.puppet_proxy_id if @host.puppet_proxy_id.nil? && @host.hostgroup.puppet_proxy_id.present?
@host.puppet_ca_proxy_id = @host.hostgroup.puppet_ca_proxy_id if @host.puppet_ca_proxy_id.nil? && @host.hostgroup.puppet_ca_proxy_id.present?

if @host.puppet.nil? && @host.hostgroup.puppet&.environment.present?
puppet = @host.puppet || @host.build_puppet
puppet.environment = @host.hostgroup.puppet&.environment
end
end

super
end
end
end
end
1 change: 1 addition & 0 deletions lib/foreman_puppet/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class Engine < ::Rails::Engine

::Api::V2::BaseController.include ForemanPuppet::Extensions::ApiBaseController
::Api::V2::HostsController.include ForemanPuppet::Extensions::ApiV2HostsController
::Api::V2::RegistrationController.prepend ForemanPuppet::Extensions::ApiV2RegistrationControllerExtensions
::Api::V2::HostgroupsController.include ForemanPuppet::Extensions::ApiHostgroupsController
::Api::V2::TemplateCombinationsController.include ForemanPuppet::Extensions::ApiTemplateCombinationsController
::Api::V2::HostsController.include ForemanPuppet::Extensions::ParametersHost
Expand Down

0 comments on commit 23b7d8a

Please sign in to comment.