Ansible registers module used to capture/store the output of a task/command.it is similar to variable declarations we can define the value in different scenarios like a conditional, logging, etc. for an example we echo uptime and hostname using the following syntax.
Here uptime is the value of the register variable, we can define any suitable value. At the last, we use the debug module with variable name. I have attached one example below for your reference.
- hosts: all
- name: System Uptime
- debug: var=uptime