From 2d46e464f75aaaf57b2fff4697d22be4605b8c5b Mon Sep 17 00:00:00 2001 From: Bernhard Suttner Date: Wed, 8 Mar 2023 22:18:34 +0100 Subject: [PATCH] Fixes #36075 - improve errata installation templates (#10444) Co-authored-by: Jeremy Lenz (cherry picked from commit c9c15fac7fbdb39ab72ffd49c178eb047990bb38) --- app/views/foreman/job_templates/install_errata.erb | 8 ++++---- .../install_errata_-_katello_ansible_default.erb | 11 ++++------- .../job_templates/install_errata_by_search_query.erb | 11 +++++------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/app/views/foreman/job_templates/install_errata.erb b/app/views/foreman/job_templates/install_errata.erb index 8250381efd1..83d22df9cef 100644 --- a/app/views/foreman/job_templates/install_errata.erb +++ b/app/views/foreman/job_templates/install_errata.erb @@ -15,9 +15,9 @@ foreign_input_sets: exclude: action,package %> <% if @host.operatingsystem.family == 'Suse' -%> - <% advisories = input(:errata).split(',').join(' ') %> + <% advisories = input(:errata).split(',').join(' ') -%> <%= render_template('Package Action - Script Default', :action => 'install -n -t patch', :package => advisories) %> -<% else %> - <% advisories = input(:errata).split(',').map { |e| "--advisory=#{e}" }.join(' ') %> +<% else -%> + <% advisories = input(:errata).split(',').map { |e| "--advisory=#{e}" }.join(' ') -%> <%= render_template('Package Action - Script Default', :action => 'update-minimal', :package => advisories) %> -<% end %> +<% end -%> diff --git a/app/views/foreman/job_templates/install_errata_-_katello_ansible_default.erb b/app/views/foreman/job_templates/install_errata_-_katello_ansible_default.erb index e354ddf6346..4174a9f7520 100644 --- a/app/views/foreman/job_templates/install_errata_-_katello_ansible_default.erb +++ b/app/views/foreman/job_templates/install_errata_-_katello_ansible_default.erb @@ -15,12 +15,9 @@ kind: job_template %> <% if @host.operatingsystem.family == 'Suse' -%> -<% advisories = input(:errata).split(',').join(' ') -%> -<%= render_template('Run Command - Ansible Default', :command => "zypper -n install -t patch #{advisories}") -%> -<% elsif @host.operatingsystem.family == 'Debian' -%> -<% advisories = input(:errata).split(',').map { |e| @host.debs_for_erratum(e) }.join(' ') -%> -<%= render_template('Run Command - Ansible Default', :command => "apt-get -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\" -y --only-upgrade install -y #{advisories}") %> + <% advisories = input(:errata).split(',').join(' ') -%> + <%= render_template('Run Command - Ansible Default', :command => "zypper -n install -t patch #{advisories}") %> <% else -%> -<% advisories = input(:errata).split(',').map { |e| "--advisory=#{e}" }.join(' ') -%> -<%= render_template('Run Command - Ansible Default', :command => "yum -y update-minimal #{advisories}") -%> + <% advisories = input(:errata).split(',').map { |e| "--advisory=#{e}" }.join(' ') -%> + <%= render_template('Run Command - Ansible Default', :command => "yum -y update-minimal #{advisories}") %> <% end -%> diff --git a/app/views/foreman/job_templates/install_errata_by_search_query.erb b/app/views/foreman/job_templates/install_errata_by_search_query.erb index 6f8de971394..3335c6eea3a 100644 --- a/app/views/foreman/job_templates/install_errata_by_search_query.erb +++ b/app/views/foreman/job_templates/install_errata_by_search_query.erb @@ -15,14 +15,13 @@ foreign_input_sets: exclude: action,package %> -<% advisory_ids = @host.advisory_ids(search: input("Errata search query")) %> +<% advisory_ids = @host.advisory_ids(search: input("Errata search query")) -%> +<% render_error(N_("No errata matching given search query")) if !input("Errata search query").blank? && advisory_ids.blank? -%> # RESOLVED_ERRATA_IDS=<%= advisory_ids.join(',') %> <% if @host.operatingsystem.family == 'Suse' -%> <%= render_template('Package Action - Script Default', :action => 'install -n -t patch', :package => advisory_ids.join(' ')) %> -<% else %> - <% raise "No errata matching given search query" if !input("Errata search query").blank? && advisory_ids.empty? %> - - <% advisories = advisory_ids.map { |e| "--advisory=#{e}" }.join(' ') %> +<% else -%> + <% advisories = advisory_ids.map { |e| "--advisory=#{e}" }.join(' ') -%> <%= render_template('Package Action - Script Default', :action => 'update-minimal', :package => advisories) %> -<% end %> +<% end -%>