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.

Reply via email to