diff --git a/ansible.cfg b/ansible.cfg index ec2f44e2..e1927717 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,2 +1,6 @@ [ssh_connection] -pipelining = True \ No newline at end of file +pipelining = True +[defaults] +stdout_callback = json +callback_whitelist = json +json_indent = 4 \ No newline at end of file diff --git a/scripts/qesap/lib/cmds.py b/scripts/qesap/lib/cmds.py index dac4a784..134ec6d0 100644 --- a/scripts/qesap/lib/cmds.py +++ b/scripts/qesap/lib/cmds.py @@ -289,8 +289,12 @@ def ansible_command_sequence(configure_data_ansible, base_project, sequence, ver ansible_cmd_seq.append({'cmd': ssh_share}) original_env = dict(os.environ) original_env['ANSIBLE_PIPELINING'] = 'True' - if profile: - original_env['ANSIBLE_CALLBACK_WHITELIST'] = 'ansible.posix.profile_tasks' + original_env['ANSIBLE_CALLBACKS_ENABLED'] = 'json' + original_env['ANSIBLE_LOAD_CALLBACK_PLUGINS'] = '1' + original_env['ANSIBLE_STDOUT_CALLBACK'] = 'json' + #original_env['ANSIBLE_CONFIG'] = os.path.join(base_project, 'ansible.cfg') + #if profile: + #original_env['ANSIBLE_CALLBACK_WHITELIST'] = 'json' if 'roles_path' in configure_data_ansible: original_env['ANSIBLE_ROLES_PATH'] = configure_data_ansible['roles_path'] @@ -345,7 +349,7 @@ def cmd_ansible(configure_data, base_project, dryrun, verbose, destroy=False, pr return Status("ok") inventory = os.path.join(base_project, 'terraform', configure_data['provider'], 'inventory.yaml') - ansible_cmd_seq = ansible_command_sequence(configure_data['ansible'], base_project, sequence, verbose, inventory, profile) + ansible_cmd_seq = ansible_command_sequence(configure_data['ansible'], base_project, sequence, False, inventory, profile) for command in ansible_cmd_seq: if dryrun: @@ -353,10 +357,7 @@ def cmd_ansible(configure_data, base_project, dryrun, verbose, destroy=False, pr else: ret, out = lib.process_manager.subprocess_run(**command) log.debug("Ansible process return ret:%d", ret) - if ret == 0: - for out_line in out: - log.debug("> %s", out_line) - else: + if ret != 0: log.error("command:%s returned non zero %d", command, ret) return Status(ret) return Status("ok") diff --git a/scripts/qesap/lib/process_manager.py b/scripts/qesap/lib/process_manager.py index f7aeb89c..d5fa89ec 100644 --- a/scripts/qesap/lib/process_manager.py +++ b/scripts/qesap/lib/process_manager.py @@ -2,6 +2,7 @@ All tools needed to manage external executable and processes ''' +import sys import subprocess import logging @@ -31,6 +32,11 @@ def subprocess_run(cmd, env=None): return (proc.returncode, []) stdout = [line.decode("utf-8") for line in proc.stdout.splitlines()] + print(f"OUTPUT START FOR COMMAND: {cmd}") + sys.stdout.flush() for line in stdout: - log.debug('OUTPUT: %s', line) + print(line) + sys.stdout.flush() + print(f"OUTPUT END FOR COMMAND: {cmd}") + sys.stdout.flush() return (0, stdout)