From 177b385dfbbc064114bc1aa81e2e2a1f1435a2ec Mon Sep 17 00:00:00 2001 From: Marc Urben Date: Sat, 23 Aug 2025 18:38:00 +0200 Subject: [PATCH] Add support for gpg-auto-import-keys option to zypper (#10661) * Add support for gpg-auto-import-keys option to zypper * Add changelog fragment * Add missing module argument_spec * Improving documentation * Improve changelog fragment --- .../10661-support-gpg-auto-impor-keys-in-zypper.yml | 2 ++ plugins/modules/zypper.py | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 changelogs/fragments/10661-support-gpg-auto-impor-keys-in-zypper.yml diff --git a/changelogs/fragments/10661-support-gpg-auto-impor-keys-in-zypper.yml b/changelogs/fragments/10661-support-gpg-auto-impor-keys-in-zypper.yml new file mode 100644 index 0000000000..333121902f --- /dev/null +++ b/changelogs/fragments/10661-support-gpg-auto-impor-keys-in-zypper.yml @@ -0,0 +1,2 @@ +minor_changes: + - zypper - support the ``--gpg-auto-import-keys`` option in zypper (https://github.com/ansible-collections/community.general/issues/10660, https://github.com/ansible-collections/community.general/pull/10661). diff --git a/plugins/modules/zypper.py b/plugins/modules/zypper.py index a9e3bf5257..99e952a97a 100644 --- a/plugins/modules/zypper.py +++ b/plugins/modules/zypper.py @@ -82,6 +82,14 @@ options: required: false default: false type: bool + auto_import_keys: + description: + - Whether to automatically import new repository signing keys. Adds C(--gpg-auto-import-keys) option to I(zypper). + - Is only used when installing. + required: false + default: false + type: bool + version_added: 11.3.0 disable_recommends: description: - Corresponds to the C(--no-recommends) option for I(zypper). Default behavior (V(true)) modifies zypper's default behavior; @@ -427,6 +435,8 @@ def get_cmd(m, subcommand): # add global options before zypper command if (is_install or is_refresh) and m.params['disable_gpg_check']: cmd.append('--no-gpg-checks') + if is_install and m.params['auto_import_keys']: + cmd.append('--gpg-auto-import-keys') if subcommand == 'search': cmd.append('--disable-repositories') @@ -609,6 +619,7 @@ def main(): type=dict(default='package', choices=['package', 'patch', 'pattern', 'product', 'srcpackage', 'application']), extra_args_precommand=dict(), disable_gpg_check=dict(default=False, type='bool'), + auto_import_keys=dict(default=False, type='bool'), disable_recommends=dict(default=True, type='bool'), force=dict(default=False, type='bool'), force_resolution=dict(default=False, type='bool'),