From c57200925f7fc3c77da9a0b671ef7328cad15d8d Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Wed, 14 Oct 2015 09:12:02 -0400 Subject: [PATCH] made syslog import optional as intel's edison custom compiles python w/o it --- lib/ansible/module_utils/basic.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 0da00053a0..60fe3233b4 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -54,7 +54,6 @@ import pipes import shlex import subprocess import sys -import syslog import types import time import select @@ -68,6 +67,12 @@ import platform import errno from itertools import repeat +try: + import syslog + HAS_SYSLOG=True +except ImportError: + HAS_SYSLOG=False + try: # Python 2 from itertools import imap @@ -1246,9 +1251,10 @@ class AnsibleModule(object): return params def _log_to_syslog(self, msg): - module = 'ansible-%s' % os.path.basename(__file__) - syslog.openlog(str(module), 0, syslog.LOG_USER) - syslog.syslog(syslog.LOG_INFO, msg) + if HAS_SYSLOG: + module = 'ansible-%s' % os.path.basename(__file__) + syslog.openlog(str(module), 0, syslog.LOG_USER) + syslog.syslog(syslog.LOG_INFO, msg) def debug(self, msg): if self._debug: