summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Garrett <lgarrett@rocketjump.eu>2023-11-10 13:49:35 +0100
committerLee Garrett <lgarrett@rocketjump.eu>2023-11-10 13:49:35 +0100
commit624064e952867e6e7a775161606bf967b625c8a1 (patch)
tree749979fdec700d99a21e4f04d947323bd0fd5935
parent77810b83a4b35ccc572640dfab87ce45af1c9fc4 (diff)
downloaddebian-ansible-core-624064e952867e6e7a775161606bf967b625c8a1.zip
Fix facter when puppet not present (Closes: #1055616)
-rw-r--r--debian/patches/0010-fix-facter.patch86
-rw-r--r--debian/patches/series1
2 files changed, 87 insertions, 0 deletions
diff --git a/debian/patches/0010-fix-facter.patch b/debian/patches/0010-fix-facter.patch
new file mode 100644
index 00000000..97ca4fd5
--- /dev/null
+++ b/debian/patches/0010-fix-facter.patch
@@ -0,0 +1,86 @@
+Description: Fix facter when installed without puppet
+Author: Brian Coca <brian.coca+git@gmail.com>
+Origin: upstream, https://github.com/ansible/ansible/pull/80645/
+Bug: https://github.com/ansible/ansible/issues/80496
+Reviewed-by: Lee Garrett <debian@rocketjump.eu>
+Last-Update: 2023-11-10
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+diff --git a/changelogs/fragments/setup_facter_fix.yml b/changelogs/fragments/setup_facter_fix.yml
+new file mode 100644
+index 00000000000000..78a6b005a4abf2
+--- /dev/null
++++ b/changelogs/fragments/setup_facter_fix.yml
+@@ -0,0 +1,2 @@
++bugfixes:
++ - setup module (fact gathering) will now try to be smarter about different versions of facter emitting error when --puppet flag is used w/o puppet.
+diff --git a/lib/ansible/module_utils/facts/other/facter.py b/lib/ansible/module_utils/facts/other/facter.py
+index 3f83999d419d5c..9b6edc0b5ceaf9 100644
+--- a/lib/ansible/module_utils/facts/other/facter.py
++++ b/lib/ansible/module_utils/facts/other/facter.py
+@@ -1,27 +1,12 @@
+-# This file is part of Ansible
+-#
+-# Ansible is free software: you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published by
+-# the Free Software Foundation, either version 3 of the License, or
+-# (at your option) any later version.
+-#
+-# Ansible is distributed in the hope that it will be useful,
+-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-# GNU General Public License for more details.
+-#
+-# You should have received a copy of the GNU General Public License
+-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
++# Copyright (c) 2023 Ansible Project
++# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+ from __future__ import (absolute_import, division, print_function)
+ __metaclass__ = type
+
+ import json
+
+-import ansible.module_utils.compat.typing as t
+-
+ from ansible.module_utils.facts.namespace import PrefixFactNamespace
+-
+ from ansible.module_utils.facts.collector import BaseFactCollector
+
+
+@@ -49,6 +34,12 @@ def run_facter(self, module, facter_path):
+ # if facter is installed, and we can use --json because
+ # ruby-json is ALSO installed, include facter data in the JSON
+ rc, out, err = module.run_command(facter_path + " --puppet --json")
++
++ # for some versions of facter, --puppet returns an error if puppet is not present,
++ # try again w/o it, other errors should still appear and be sent back
++ if rc != 0:
++ rc, out, err = module.run_command(facter_path + " --json")
++
+ return rc, out, err
+
+ def get_facter_output(self, module):
+
+From dace8abd19b1ef17d6534d881234e4771263dd1b Mon Sep 17 00:00:00 2001
+From: Brian Coca <brian.coca+git@gmail.com>
+Date: Wed, 26 Apr 2023 12:30:08 -0400
+Subject: [PATCH 2/2] restore import
+
+---
+ lib/ansible/module_utils/facts/other/facter.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lib/ansible/module_utils/facts/other/facter.py b/lib/ansible/module_utils/facts/other/facter.py
+index 9b6edc0b5ceaf9..063065251dd36e 100644
+--- a/lib/ansible/module_utils/facts/other/facter.py
++++ b/lib/ansible/module_utils/facts/other/facter.py
+@@ -6,6 +6,8 @@
+
+ import json
+
++import ansible.module_utils.compat.typing as t
++
+ from ansible.module_utils.facts.namespace import PrefixFactNamespace
+ from ansible.module_utils.facts.collector import BaseFactCollector
+
diff --git a/debian/patches/series b/debian/patches/series
index 9eedd1c6..340d630e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
0005-use-py3.patch
0009-resolvelib_compat.patch
+0010-fix-facter.patch