Hi All
I have this ansible code where i need output of all these commands in one file, however, all i am getting is either output of first command or second command if i change the following to 0,1,2 however ansible is not appending/writing all outputs into a single file.
Appreciate if there is a method which members could suggest to make it work.
"{{ print_output.stdout[1] }}
- name: Name servers
ios_command:
authorize: yes
provider: "{{ cli }}"
commands:
- show ip name-servers
- show ip int brief
- show logging | in host
register: print_output
- name: save output to a file
copy: content="{{ print_output.stdout[1] }}" dest="/opt/ansible/dev/Dheeraj/verf/adnan/NTP/{{ inventory_hostname }}.txt"
Can you try this
Use this to write several strings into a file:
- name: save output to a file
lineinfile:
create: yes
line: "{{item}}"
path: ./output/{{ inventory_hostname }}.txt
with_items: "{{ print_output.stdout[1] }}"--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/60f51826-3f20-4421-97ed-1e79724c8473n%40googlegroups.com.
Thanks,
Pushparaj G
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/93146581-f3b0-4bf4-8625-011b5c5a8d59n%40googlegroups.com.
Thanks,
Pushparaj G
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/730ddb05-3e2a-4561-9034-8f06a59def97n%40googlegroups.com.