-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP-DO NOT MERGE: Add json output #222
base: main
Are you sure you want to change the base?
Conversation
stdout_callback = json | ||
callback_whitelist = json | ||
json_indent = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the ones to use in order to have json output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
master what happend with the profile code? if we decided to include the json format
@@ -345,18 +349,15 @@ 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the verbose output, not sure if it impacts json output in any way, I think not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice master!!
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.cfg
for 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.