# How to login to Avocent servers and run ansible playbooks on the Network devices which are connected serially

**URL:** <https://forum.ansible.com/t/how-to-login-to-avocent-servers-and-run-ansible-playbooks-on-the-network-devices-which-are-connected-serially/25515>\
**Category:** Ansible Project\
**Created:** [September 18, 2017, 9:11pm UTC](https://forum.ansible.com/t/how-to-login-to-avocent-servers-and-run-ansible-playbooks-on-the-network-devices-which-are-connected-serially/25515 "2017-09-18T21:11:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mini](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@Mini](https://forum.ansible.com/u/Mini)\
**Post date:** [September 18, 2017, 9:11pm UTC](https://forum.ansible.com/t/how-to-login-to-avocent-servers-and-run-ansible-playbooks-on-the-network-devices-which-are-connected-serially/25515/1 "2017-09-18T21:11:52Z")

</div>

I have been redirected from git hub issue list to here. Could someone please take a look and suggest:

I am trying to work on a scenario in which I want to access Cisco and Juniper network devices and run my ansible network modules like get facts, get config, push config commands on them through ansible. The network devices are connected via console ports to an Avocent AS6000 server. So from a CentOS machine which is my ansible host machine, I want to login to the Avocent Server and then access the network devices using ansible playbooks. I am not sure how to go about it. Can anyone please guide me. I am new to this and sorry if i have posted in the wrong forum.  
Please note: I am able to run playbooks directly through management port of the Network devices. This serial console route is a second way to access the devices and need to write playbooks in case the management IP goes down or is inaccessible.

COMPONENT NAME  
Network Modules

ANSIBLE VERSION  
ansible --version  
ansible 2.3.2.0  
config file = /etc/ansible/ansible.cfg  
configured module search path = Default w/o overrides  
python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]  
`  
OS / ENVIRONMENT  
Centos7  
Avocent Server ACS6000  
Juniper EX2200

SUMMARY  
Could someone please guide on how do I use ansible to login from my CentOS machine to an Avocent server and then navigate to different network devices that are connected serially on each port and run playbooks on it. Both CentOS and Avocent server is on the same network. I am able to ssh to the avocent device, but how do I access the network devices from it.

Manual steps to access:

1. Login to avocent server via ssh through putty.
2. Go to cli mode. by typing cli command
3. Go to a particular folder which gives the port list of all the connected devices. The port number corresponds to each device connected serially to it

Also, here is the playbook to check ssh connectivity:

- hosts: avocent  
gather\_facts: no  
connection: local

``  
ACTUAL RESULTS  
ok: [avocentfirst] =\> {  
“changed”: false,  
“elapsed”: 0,  
“invocation”: {  
“module\_args”: {  
“active\_connection\_states”: [  
“ESTABLISHED”,  
“SYN\_SENT”,  
“SYN\_RECV”,  
“FIN\_WAIT1”,  
“FIN\_WAIT2”,  
“TIME\_WAIT”  
],  
“connect\_timeout”: 5,  
“delay”: 0,  
“exclude\_hosts”: null,  
“host”: “xx.xx.xx.xx”,  
“path”: null,  
“port”: 22,  
“search\_regex”: null,  
“sleep”: 1,  
“state”: “started”,  
“timeout”: 5  
}  
},  
“path”: null,  
“port”: 22,  
“search\_regex”: null,  
“state”: “started”  
}

Below is the failure message when I try to acess the network device:  
Failure message:

```auto
"msg": "unable to connect to xx.xx.xx.x..: ConnectError(host: xx.xx.xx.xx, msg: Unexpected session close\

```

---

<div class="post-metadata">

**Author:** ![ganeshrn](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ganeshrn/32/1021_2.png) [@ganeshrn](https://forum.ansible.com/u/ganeshrn)\
**Post date:** [September 19, 2017, 9:54am UTC](https://forum.ansible.com/t/how-to-login-to-avocent-servers-and-run-ansible-playbooks-on-the-network-devices-which-are-connected-serially/25515/2 "2017-09-19T09:54:58Z")

</div>

Ansible does not support serial console connection.  
However, there are other ways to bootstrap a working ssh connection to the network device and that can be managed by Ansible.

One possible way is you can use [pyserial](https://pypi.python.org/pypi/pyserial) to write a script that connects to the network device over serial console connection and perform minimal configuration that enables Ansible to talk to Network device over ssh.

Regards,  
Ganesh

---

<div class="post-metadata">

**Author:** ![Vinita\_Shah](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@Vinita\_Shah](https://forum.ansible.com/u/Vinita_Shah)\
**Post date:** [March 19, 2018, 7:07pm UTC](https://forum.ansible.com/t/how-to-login-to-avocent-servers-and-run-ansible-playbooks-on-the-network-devices-which-are-connected-serially/25515/3 "2018-03-19T19:07:31Z")

</div>

Could you get this to work?

I am running into the same issue.

Thank you!
