From c2992fbb8138da69602f2ad515d7f666c70b67a2 Mon Sep 17 00:00:00 2001
From: Pieter Hollants <pieter@hollants.com>
Date: Wed, 5 Oct 2016 15:14:25 +0200
Subject: [PATCH] zypper_repository: Prepend --gpg-auto-import-keys before
 refresh command (#3088)

Fixes #3086.
---
 lib/ansible/modules/extras/packaging/os/zypper_repository.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/ansible/modules/extras/packaging/os/zypper_repository.py b/lib/ansible/modules/extras/packaging/os/zypper_repository.py
index e6e263c3e5..db553970e8 100644
--- a/lib/ansible/modules/extras/packaging/os/zypper_repository.py
+++ b/lib/ansible/modules/extras/packaging/os/zypper_repository.py
@@ -280,9 +280,10 @@ def get_zypper_version(module):
 
 def runrefreshrepo(module, auto_import_keys=False, shortname=None):
     "Forces zypper to refresh repo metadata."
-    cmd = _get_cmd('refresh', '--force')
     if auto_import_keys:
-        cmd.append('--gpg-auto-import-keys')
+        cmd = _get_cmd('--gpg-auto-import-keys', 'refresh', '--force')
+    else:
+        cmd = _get_cmd('refresh', '--force')
     if shortname is not None:
         cmd.extend(['-r', shortname])