'Passing port: 23 in ios_command module where default is (22)

I am building a workflow where I try to SSH a device if that doesn't work I will telnet to the device, If telnet is succesfull, I will continue my workflow,
Now when SSH is working, my play is running successfully that is ios_command module works, but when I make the connection via telnet, ios_command doesnt work because the default port is 22.

I am able run cisco ios commands using this

But it would be a lot easier if I could just use the ios_command module.

In the documentation I found the port option but it is not mentioned where should I use it:
https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_command_module.html#parameter-provider/port

- name: testing port 23
  ios_command:
    commands:
      - show version
  register: x
- debug: var=x 

In this code snippet where should I use port, I have tried to pass port: in vars.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source