File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
src/ansible_runner/display_callback/callback Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 34
34
from copy import copy
35
35
36
36
# Ansible
37
+ from ansible import __version__ as ansible_version_str
37
38
from ansible import constants as C
38
39
from ansible .plugins .callback import CallbackBase
39
40
from ansible .plugins .loader import callback_loader
40
41
from ansible .utils .display import Display
42
+ from ansible .utils .multiprocessing import context as multiprocessing_context
41
43
42
44
43
45
DOCUMENTATION = '''
67
69
68
70
CENSORED = "the output has been hidden due to the fact that 'no_log: true' was specified for this result"
69
71
72
+ _ANSIBLE_VERSION = tuple (int (p ) for p in ansible_version_str .split ('.' )[:2 ])
73
+ _ANSIBLE_217 = _ANSIBLE_VERSION >= (2 , 17 )
74
+
70
75
71
76
def current_time ():
72
77
return datetime .datetime .now (datetime .timezone .utc )
@@ -282,10 +287,18 @@ def wrapper(*args, **kwargs):
282
287
Display .verbose = with_verbosity (Display .verbose )
283
288
284
289
290
+ @functools .lru_cache (maxsize = 2 )
291
+ def _is_child ():
292
+ return multiprocessing_context .parent_process () is not None
293
+
294
+
285
295
def display_with_context (f ):
286
296
287
297
@functools .wraps (f )
288
298
def wrapper (* args , ** kwargs ):
299
+ if _ANSIBLE_217 and _is_child ():
300
+ return f (* args , ** kwargs )
301
+
289
302
log_only = args [5 ] if len (args ) >= 6 else kwargs .get ('log_only' , False )
290
303
stderr = args [3 ] if len (args ) >= 4 else kwargs .get ('stderr' , False )
291
304
event_uuid = event_context .get ().get ('uuid' , None )
You can’t perform that action at this time.
0 commit comments