Ansible can't access my network devices. Getting : FAILED! => {"changed": false, "msg": "Connection type ssh is not valid for this module"}

Hi,

I’m new to Ansible and trying to write my first playbook.

But i keep getting an error: fatal: [RTR1]: FAILED! => {“changed”: false, “msg”: “Connection type ssh is not valid for this module”}

I’m suspecting Ansible is complaining about my Cisco devices ssh settings (running diffie-hellman-group1-sha1) but I’m not sure if that’s correct. Will appreciate your assistance

Hello,

You need to use ansible_connection=network_cli. This connection plugin provides a connection to remote devices over the SSH and implements a CLI shell. It is typically used by network devices for sending CLI commands to network devices and also receiving information from them. If your devices are running Cisco IOS, please have a look at the platform guide.

You can also refer to https://docs.ansible.com/ansible/latest/network/index.html for more information on getting started with Ansible Network Automation.

Thank you!

(attachments)

Palmer,

When connecting to network devices, you need to specify an appropriate connection plugin, such as network_cli, and specify the network OS in inventory.

Thanks for the input. I did try what you suggested but I’m here the same issue. Please take a look at the screenshot and let me know if you see something

I’m pretty new to and ran into the same issue. Is your hosts file defined like this:

[ios]
RTR1
RTR2

Did you define something in your config.yml?

Here is what i have defined/configured in hosts and config.yml files:

I see that the group name in inventory is “Cisco_Router”, however, the group_vars file is named as “ios.yaml”. Those two should be identical in this approach.

Please have a look at https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#organizing-host-and-group-variables.

Thanks!

(attachments)

Your group_vars yml file should be named identical to the group-name you put your device(s). This is why the variables are not being called. If you define these in your playbook it would work and that can help later isolate where things are not working.

Thank you everyone for your help on this. This issue has been resolved. As you previously mentioned, I made sure the group_vars yml file was named identical with the group-name i have my devices

Try adding the “connection:local” under your hosts

  • hosts: “myhost”

connection: local