From f2d4912f2937adc437ec426ada74553442f9ccbe Mon Sep 17 00:00:00 2001
From: Konstantin Gribov <grossws@gmail.com>
Date: Fri, 25 May 2018 22:41:59 +0300
Subject: [PATCH] module_utils/facts: override pkg_mgr for ALT Linux (#38004)

Overrides `pkg_mgr` fact to `apt_rpm` if:
- found package manager is `apt`;
- `/usr/bin/rpm` is present;
- `/usr/bin/dpkg` is absent.

Fixes #37997
---
 lib/ansible/module_utils/facts/system/pkg_mgr.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/ansible/module_utils/facts/system/pkg_mgr.py b/lib/ansible/module_utils/facts/system/pkg_mgr.py
index db18bb0ee5..a8fcf0929d 100644
--- a/lib/ansible/module_utils/facts/system/pkg_mgr.py
+++ b/lib/ansible/module_utils/facts/system/pkg_mgr.py
@@ -78,5 +78,10 @@ class PkgMgrFactCollector(BaseFactCollector):
             if os.path.exists(pkg['path']):
                 pkg_mgr_name = pkg['name']
 
+        if pkg_mgr_name == 'apt' and \
+                os.path.exists('/usr/bin/rpm') and \
+                not os.path.exists('/usr/bin/dpkg'):
+            pkg_mgr_name = 'apt_rpm'
+
         facts_dict['pkg_mgr'] = pkg_mgr_name
         return facts_dict