diff --git a/app/helpers/provisioning_templates_helper.rb b/app/helpers/provisioning_templates_helper.rb index bf2db6eee46..b1118542e1a 100644 --- a/app/helpers/provisioning_templates_helper.rb +++ b/app/helpers/provisioning_templates_helper.rb @@ -67,6 +67,15 @@ def permitted_actions(template) end end + def pxe_with_building_hosts?(template) + kinds = ["PXELinux", "PXEGrub"] + os_ids = template.operatingsystem_ids + template.respond_to?(:template_kind) && + template.template_kind.present? && + kinds.include?(template.template_kind.name) && + Host.where(:build => true, :operatingsystem_id => os_ids).any? + end + private def locations_only? diff --git a/app/views/templates/_form.html.erb b/app/views/templates/_form.html.erb index 532158944c0..b91a894020a 100644 --- a/app/views/templates/_form.html.erb +++ b/app/views/templates/_form.html.erb @@ -35,6 +35,11 @@ "http://www.theforeman.org/manuals/#{SETTINGS[:version].short}/index.html#4.4.3ProvisioningTemplates", :rel => 'external')).html_safe) %> <% end -%> + <% if pxe_with_building_hosts?(@template) -%> + <%= alert :class => 'alert-warning', :header => '', + :text => icon_text("warning-sign", (_("Warning: The template is associated to at least one host in build mode. To apply the change, disable and enable build mode on hosts to update the live templates."))) %> + <% end -%> +