Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #36207 - Setup puppet during Host Registration #402

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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