From 699995e29ed6fcd3b39fc9fd99f639b08bab4060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20K=C3=BChlhorn?= Date: Tue, 1 Oct 2024 17:08:11 +0200 Subject: [PATCH] Fixes #37870 - Auto-import new GPG keys on SLES --- app/services/foreman/renderer/scope/macros/host_template.rb | 2 +- .../unattended/provisioning_templates/snippet/puppet_setup.erb | 2 +- .../provisioning_templates/snippet/saltstack_setup.erb | 2 +- test/unit/foreman/renderer/scope/macros/host_template_test.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/foreman/renderer/scope/macros/host_template.rb b/app/services/foreman/renderer/scope/macros/host_template.rb index a062c82fce7..12b0460ff6b 100644 --- a/app/services/foreman/renderer/scope/macros/host_template.rb +++ b/app/services/foreman/renderer/scope/macros/host_template.rb @@ -173,7 +173,7 @@ def install_packages(packages) <<~CMD #{banner} zypper refresh - zypper -n install #{packages} + zypper -n --gpg-auto-import-keys install #{packages} CMD else raise UnsupportedOS.new diff --git a/app/views/unattended/provisioning_templates/snippet/puppet_setup.erb b/app/views/unattended/provisioning_templates/snippet/puppet_setup.erb index 8dba07a29c6..38cb12ee24a 100644 --- a/app/views/unattended/provisioning_templates/snippet/puppet_setup.erb +++ b/app/views/unattended/provisioning_templates/snippet/puppet_setup.erb @@ -60,7 +60,7 @@ rpmkeys --import https://yum.puppet.com/RPM-GPG-KEY-puppetlabs rpmkeys --import https://yum.puppet.com/RPM-GPG-KEY-puppet <% end -%> <% if @host.provision_method == 'image' -%> -/usr/bin/zypper -n install <%= linux_package %> +/usr/bin/zypper -n --gpg-auto-import-keys install <%= linux_package %> <% end -%> <% elsif os_family == 'Windows' -%> $puppet_agent_msi = "${env:TEMP}\<%= windows_package %>" diff --git a/app/views/unattended/provisioning_templates/snippet/saltstack_setup.erb b/app/views/unattended/provisioning_templates/snippet/saltstack_setup.erb index 4d6662c1898..71523721169 100644 --- a/app/views/unattended/provisioning_templates/snippet/saltstack_setup.erb +++ b/app/views/unattended/provisioning_templates/snippet/saltstack_setup.erb @@ -22,7 +22,7 @@ else yum -t -y install salt-minion fi <% elsif @host.operatingsystem.family == 'Suse' -%> - /usr/bin/zypper -n install salt-minion + /usr/bin/zypper -n --gpg-auto-import-keys install salt-minion <% end -%> cat > <%= etc_path %>/minion.d/minion.conf << EOF diff --git a/test/unit/foreman/renderer/scope/macros/host_template_test.rb b/test/unit/foreman/renderer/scope/macros/host_template_test.rb index 5a1ca55030d..68fca3e9c85 100644 --- a/test/unit/foreman/renderer/scope/macros/host_template_test.rb +++ b/test/unit/foreman/renderer/scope/macros/host_template_test.rb @@ -294,7 +294,7 @@ def host_info @scope.instance_variable_set('@host', host) command = @scope.install_packages('pkg1') - assert_includes command, 'zypper -n install pkg1' + assert_includes command, 'zypper -n --gpg-auto-import-keys install pkg1' end end