From 4337b7a7770123e1634ccc13f55c321b89667bdf Mon Sep 17 00:00:00 2001
From: Eduardo Suarez-Santana <e.suarezsantana@gmail.com>
Date: Thu, 5 Oct 2017 13:45:14 +0100
Subject: [PATCH] Fix rpm_key absent. (#31045)

When keyid is 8 charactes long, drop_key function cuts everything
issuing an error: "package gpg-pubkey- is not installed"
---
 lib/ansible/modules/packaging/os/rpm_key.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ansible/modules/packaging/os/rpm_key.py b/lib/ansible/modules/packaging/os/rpm_key.py
index f6deaff0674..fce57f86340 100644
--- a/lib/ansible/modules/packaging/os/rpm_key.py
+++ b/lib/ansible/modules/packaging/os/rpm_key.py
@@ -183,7 +183,7 @@ class RpmKey(object):
 
     def drop_key(self, keyid):
         if not self.module.check_mode:
-            self.execute_command([self.rpm, '--erase', '--allmatches', "gpg-pubkey-%s" % keyid[8:].lower()])
+            self.execute_command([self.rpm, '--erase', '--allmatches', "gpg-pubkey-%s" % keyid[-8:].lower()])
 
 
 def main():