This module has the same function as the raw command module, but it is more optimized. It allows for multiple options and it has the capacity to use its return values for other tasks. As an example of a playbook, we will run a command and then collect its output for later use:
- name: run a simple command
command: cat ~/raw.txt
register: rawtxt
- debug: var=rawtxt.stdout
The output of the playbook will look as follows:
This module lacks the capacity to understand special environment variables, such as $PATH, Linux pipelining, and the redirection special characters. If this is necessary for your particular use case, use the next module on the list, shell.