Ansible: redirect stdout AND stderr
To capture output of the command in ansible i use "shell" module.
It works OK as long as the command gives stdout. However, if the command gives ERROR message, it creates empty file. Eg. executing: systemctl status iptables on the system without "iptables.service" installed should display: "Unit iptables.service could not be found" Unfortunately, ansible shell module does not redirect this msg and creates empty file. Is there a way to redirect also error output to the file? Below my code Code:
- hosts: all |
Code:
before: shell: "systemctl status iptables > /tmp/iptables.txt" |
All times are GMT -5. The time now is 07:28 PM. |