Hello Everyone,
I use ansible 2.7, I’m trying to use the ‘telnet’ module to connect to Cisco devices with IOS but it has the following error: ‘**ERROR!’ Telnet 'is not a valid attribute to play "**any ideas?
Hello Everyone,
I use ansible 2.7, I’m trying to use the ‘telnet’ module to connect to Cisco devices with IOS but it has the following error: ‘**ERROR!’ Telnet 'is not a valid attribute to play "**any ideas?
You playbook is wrong.
Hi, it would help to paste your playbook here. Invoking tasks from a playbook requires specific syntax - one option is under ‘tasks’ - see https://docs.ansible.com/ansible/latest/user_guide/playbooks_intro.html
Alternately you can have your tasks in a role and call the role from your playbook. Hope that helps. Regards, Straff
Hi,
First of all thanks for the answers, below is my playbook and then the error message.
name: Coletct Information Switches
connection: network_cli
gather_facts: false
hosts: lab_telnet
tasks:
name: send configuration commands to IOS
telnet:
user: admin
password: xxxx
login_prompt: "Username: "
prompts:
“[>|#]”
command:
terminal length 0
show run
root@DESKTOP-5B1T804:/etc/ansible# ansible-playbook telnet.yml
ERROR! ‘telnet’ is not a valid attribute for a Play
The error appears to have been in ‘/etc/ansible/telnet.yml’: line 8, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
Please repost using a fixed width font so we can check your indentation. Make sure you post your ENTIRE playbook.
Also, YAML code should always start with three hyphens on a line by themselves.
Regards, K.
I believe you need to have two spaces indentation for the telnet task