Most command modules return stdout and stderr so that you can reference them with a register variable.
command: whoami
register: returned_vars
Then you can use returned_vars.stdout or returned_vars.stderr in subsequent tasks such as one using set_stats to assign to another variable for use in later jobs if using a workflow or set_fact for use in the current playbook.