Conversation
| [defaults] | ||
| stdout_callback = json | ||
| callback_whitelist = json | ||
| json_indent = 4 No newline at end of file |
There was a problem hiding this comment.
These changes do not matter, as the cfg file is not used. Look at the description to use it in the future
| 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' |
There was a problem hiding this comment.
These are the ones to use in order to have json output
There was a problem hiding this comment.
master what happend with the profile code? if we decided to include the json format
|
|
||
| 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) |
There was a problem hiding this comment.
Removed the verbose output, not sure if it impacts json output in any way, I think not
There was a problem hiding this comment.
Maybe not but will afect this pr already merge os-autoinst/os-autoinst-distri-opensuse#18787
| print(line) | ||
| sys.stdout.flush() | ||
| print(f"OUTPUT END FOR COMMAND: {cmd}") | ||
| sys.stdout.flush() |
There was a problem hiding this comment.
This part needed to change, otherwise the logging messages were mixed with the json output. This was strange and shouldn't happen, since this whole execution is serial and not parallel, but I think that the print commands stacked up instead of being immediately delivered to stdout, so at some point some of the latter logging messages were mixed in.
This was fixed by using sys.stdout.flush() after each line printing, to send it to stdout immediatelly, so... I was probably right? Dunno. But it works.
DO NOT MERGE this is just an example showcasing things that need to be done to use json output for ansible in qe-sap deployment.
IMPORTANT NOTES:
ansible.cfgfor stuff, by addingin cmds.py.
EXAMPLE OUTPUT:
https://openqa.suse.de/tests/14152898/logfile?filename=deploy_qesap_ansible-qesap_exec_ansible.log.txt
Just go down some lines, and you'll see the output. Each playbook is another json.