Re: [ansible-project] ios_command multiple commands

2019-01-05 Thread Eduardo Nunes Pereira
Tks Kumar, Your tip worked for me.



Em sáb, 5 de jan de 2019 às 03:01, Veera Kumar 
escreveu:

> 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
>
>
> On Sat, 5 Jan 2019, 01:21 Eduardo Nunes Pereira  wrote:
>
>> - 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?
>>
>> --
>> 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-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@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.
>>
> --
> 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-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAOfyRijr8mEgoUZg6f2mGWbERPpz0iq8WQVDsEbMYh%3DSbFAhFw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAPS8ecn7hptL%3DkBX3GKpEZH9v8Qxa%3DB%2BcoMzX1PqSgg%3D1zwz6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] ios_command multiple commands

2019-01-04 Thread Veera Kumar
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


On Sat, 5 Jan 2019, 01:21 Eduardo Nunes Pereira  - 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?
>
> --
> 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-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@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.
>

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAOfyRijr8mEgoUZg6f2mGWbERPpz0iq8WQVDsEbMYh%3DSbFAhFw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.