Hi

I asked explicitly (twice) for the value of the print_output variable.
But you again did something else, which gives an error.
Please try to read carefully and try again with just the print_output variable.

On Thu, 3 Jun 2021 at 07:43, Djay wadhwa <[email protected]> wrote:
>
> Hi D
>
> Ran this code and got the error.
>
>
>    - name: TACACS
>       ios_command:
>           authorize: yes
>           provider: "{{ cli }}"
>           commands:
>             - show run | in address ipv4
>             - show ver
>
>       register: print_output
>
>     -  debug: var=print_output.stdout_lines
>
>     - name: save output to a file
>       copy: content="{{ print_output.stdout[] }}" 
> dest="/opt/ansible/dev/Dheeraj/verf/adnan/TACACS/{{ inventory_hostname }}.txt"
>
> ======
>
> Error
>
> fatal: [SURRDEN-NRT001]: FAILED! => {}
>
> MSG:
>
> The task includes an option with an undefined variable. The error was: list 
> object has no element ()
>
> The error appears to have been in '/opt/ansible/dev/Dheeraj/ntp.yml': line 
> 64, column 7, but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>
>     - name: save output to a file
>       ^ here
>
> exception type: <class 'ansible.errors.AnsibleUndefinedVariable'>
> exception: list object has no element ()
>         to retry, use: --limit @/opt/ansible/dev/Dheeraj/ntp.retry
>
>
>
> On Tuesday, June 1, 2021 at 11:17:17 PM UTC+10 [email protected] wrote:
>>
>> On Tue, 1 Jun 2021 at 13:10, Djay wadhwa <[email protected]> wrote:
>> >
>> > Hi Dick I think if we use print_output.stdout[1] }} without 0 or 1 in it, 
>> > it will throw a syntax error.
>> >
>> > Print_output.stdout alone might be invalid.
>>
>> Please let's not waste more time by thinking of what might be.
>> Instead post the value of the print_output (as I already requested),
>> so we can know for sure.
>
> --
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/bd8ee1ae-aa61-4dd0-b674-9eb94160655cn%40googlegroups.com.



-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwNa8faF%3D-ZaT4XDY6fJ1r6%3DRo5eGSTF2suDiPGxCJpUKA%40mail.gmail.com.

Reply via email to