From 9bb05b72b2af60172d7db914229aa629fd5e7a61 Mon Sep 17 00:00:00 2001
From: Adam Miller <admiller@redhat.com>
Date: Thu, 7 Feb 2019 14:16:38 -0600
Subject: [PATCH] correctly detect pkg_mgr on fedora/rhel/centos rpm-ostree
 installed (#49256)

Check the path /run/ostree-booted which I'm told by upstream that it
will always be present when a host system is Fedora/RHEL/CentOS
Atomic/CoreOS vs "traditional" distro instance to detect the
non-traditional instance and ensure pkg_mgr selection is correct

Signed-off-by: Adam Miller <admiller@redhat.com>
---
 changelogs/fragments/49184-facts-rpm-ostree-pkgmgr.yml | 2 ++
 lib/ansible/module_utils/facts/system/pkg_mgr.py       | 2 ++
 2 files changed, 4 insertions(+)
 create mode 100644 changelogs/fragments/49184-facts-rpm-ostree-pkgmgr.yml

diff --git a/changelogs/fragments/49184-facts-rpm-ostree-pkgmgr.yml b/changelogs/fragments/49184-facts-rpm-ostree-pkgmgr.yml
new file mode 100644
index 00000000000..871f785c89a
--- /dev/null
+++ b/changelogs/fragments/49184-facts-rpm-ostree-pkgmgr.yml
@@ -0,0 +1,2 @@
+bugfixes:
+- "facts - properly detect package manager for a Fedora/RHEL/CentOS system that has rpm-ostree installed"
diff --git a/lib/ansible/module_utils/facts/system/pkg_mgr.py b/lib/ansible/module_utils/facts/system/pkg_mgr.py
index ebb19944ebf..e40c5e028bc 100644
--- a/lib/ansible/module_utils/facts/system/pkg_mgr.py
+++ b/lib/ansible/module_utils/facts/system/pkg_mgr.py
@@ -61,6 +61,8 @@ class PkgMgrFactCollector(BaseFactCollector):
 
     def _check_rh_versions(self, pkg_mgr_name, collected_facts):
         if collected_facts['ansible_distribution'] == 'Fedora':
+            if os.path.exists('/run/ostree-booted'):
+                return "atomic_container"
             try:
                 if int(collected_facts['ansible_distribution_major_version']) < 23:
                     for yum in [pkg_mgr for pkg_mgr in PKG_MGRS if pkg_mgr['name'] == 'yum']: