I have this in my playbook which execute a command on remote server and enters its log on local server.
- name: run script
shell: runuser -l testuser -c "/tmp/test.sh"
register: myshell_output
- name: copy output to a local file
lineinfile:
dest: /thesaurus/output
line: "{{ item }}"
insertafter: EOF
with_items:
- "#####################Beginning##########################"
- "{{ myshell_output.stdout }}"
- "########################END#############################"
delegate_to: localhost
the output is always shown on screen and troubleshooting gets hard and distracting.
TASK [run script] ************
changed: [1.1.1.1]
changed: [2.2.2.2]
TASK [copy output to a local file] ***********
changed: [1.1.1.1 -> localhost] =>
(item=#####################Beginning##########################)
ok: [2.2.2.2 -> localhost] =>
(item=#####################Beginning##########################)
{
REALLY LONG AND BIG OUTPUT!
}
changed: [1.1.1.1 -> localhost] =>
(item=########################END#############################)
ok: [2.2.2.2 -> localhost] =>
(item=########################END#############################)
is it possible to prevent Ansible from printing these output on screen and just insert output to a file?