ios_command multiple commands

8 views
Skip to first unread message

Eduardo Nunes Pereira

unread,
Jan 4, 2019, 2:51:03 PM1/4/19
to Ansible Project
- name: Network Getting Started First Playbook
connection: network_cli
gather_facts: false
hosts: lab
tasks:

- name: run multiple commands on remote nodes
ios_command:
commands:
- show run
register: output

- name: save output
copy:
content: "{{ output.stdout[0] }}"
dest: "/etc/ansible/backup/{{ inventory_hostname }}.txt"




Have you had the chance to save a set of multiple commands on file, just save the first one from the list, does anyone have the same scenario?

Veera Kumar

unread,
Jan 5, 2019, 12:01:14 AM1/5/19
to ansible...@googlegroups.com
Hi,

You can give list of commands and all the outputs will register in mentioned variable name. And instead output.stdout[0] just give output.stdout.

But the problem is variable I.e output.stdout will only contain outputs only. Means issued command will not be there. 

Try with blockinfile module to have command1 
output of command1
Command2
Output of command2

Thanks,
Veera 


--
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 post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/05fc87c6-0e0d-4841-b6ed-32690a95cc86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eduardo Nunes Pereira

unread,
Jan 5, 2019, 9:34:45 PM1/5/19
to ansible...@googlegroups.com
Tks Kumar, Your tip worked for me.



Reply all
Reply to author
Forward
0 new messages