From 9a075b5917c95b4adb6b34c089e7e9ca23be5e1a Mon Sep 17 00:00:00 2001 From: Fabio Alessandro Locati Date: Fri, 9 Dec 2016 22:36:39 +0000 Subject: [PATCH] Avoid using an object if it does not exists (#19058) --- lib/ansible/modules/system/sefcontext.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/ansible/modules/system/sefcontext.py b/lib/ansible/modules/system/sefcontext.py index f1000b34cc1..5ca1fc4e55c 100644 --- a/lib/ansible/modules/system/sefcontext.py +++ b/lib/ansible/modules/system/sefcontext.py @@ -103,16 +103,17 @@ except ImportError: HAVE_SEOBJECT=False ### Add missing entries (backward compatible) -seobject.file_types.update(dict( - a = seobject.SEMANAGE_FCONTEXT_ALL, - b = seobject.SEMANAGE_FCONTEXT_BLOCK, - c = seobject.SEMANAGE_FCONTEXT_CHAR, - d = seobject.SEMANAGE_FCONTEXT_DIR, - f = seobject.SEMANAGE_FCONTEXT_REG, - l = seobject.SEMANAGE_FCONTEXT_LINK, - p = seobject.SEMANAGE_FCONTEXT_PIPE, - s = seobject.SEMANAGE_FCONTEXT_SOCK, -)) +if HAVE_SEOBJECT: + seobject.file_types.update(dict( + a = seobject.SEMANAGE_FCONTEXT_ALL, + b = seobject.SEMANAGE_FCONTEXT_BLOCK, + c = seobject.SEMANAGE_FCONTEXT_CHAR, + d = seobject.SEMANAGE_FCONTEXT_DIR, + f = seobject.SEMANAGE_FCONTEXT_REG, + l = seobject.SEMANAGE_FCONTEXT_LINK, + p = seobject.SEMANAGE_FCONTEXT_PIPE, + s = seobject.SEMANAGE_FCONTEXT_SOCK, + )) ### Make backward compatible option_to_file_type_str = dict(