From eb40ecc843d2afe530a2cb5b31c733373e52f7b6 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Tue, 12 May 2020 01:31:08 -0400 Subject: [PATCH] Check for correct version of systemd Python library (#60692) Fix issue where some versions of systemd don't have journal.sendv --- changelogs/fragments/60595-systemd_import.yml | 2 ++ lib/ansible/module_utils/basic.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/60595-systemd_import.yml diff --git a/changelogs/fragments/60595-systemd_import.yml b/changelogs/fragments/60595-systemd_import.yml new file mode 100644 index 00000000000..226b244886c --- /dev/null +++ b/changelogs/fragments/60595-systemd_import.yml @@ -0,0 +1,2 @@ +minor_changes: +- Add an additional check for importing journal from systemd-python module (https://github.com/ansible/ansible/issues/60595). diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index a4d211f4d40..9c0cc308a28 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -65,7 +65,9 @@ except ImportError: try: from systemd import journal - has_journal = True + # Makes sure that systemd.journal has method sendv() + # Double check that journal has method sendv (some packages don't) + has_journal = hasattr(journal, 'sendv') except ImportError: has_journal = False