Stdout processing

Simple question, what’s the best way to capture stdout from a task that is performed? For example I want to run a command to gather some telemetry from a switch but is using the debug the best way to get the stdout data? I feel like there is a different way to do this without using debug.

Use a registered variable to access the return data.

See example here: https://gist.github.com/privateip/6d3c2eb6a7301a4d20eda17af2b19be0

More about registered variables here: http://docs.ansible.com/ansible/playbooks_variables.html#sts=Registered Variables%C2%B6