# YAML loop is giving me error: unable to open shell // NX\_OS and IOS modules

**URL:** <https://forum.ansible.com/t/yaml-loop-is-giving-me-error-unable-to-open-shell-nx-os-and-ios-modules/25290>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 18, 2017, 10:57am UTC](https://forum.ansible.com/t/yaml-loop-is-giving-me-error-unable-to-open-shell-nx-os-and-ios-modules/25290 "2017-08-18T10:57:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![erotski](https://avatars.discourse-cdn.com/v4/letter/e/b9bd4f/32.png) [@erotski](https://forum.ansible.com/u/erotski)\
**Post date:** [August 18, 2017, 10:57am UTC](https://forum.ansible.com/t/yaml-loop-is-giving-me-error-unable-to-open-shell-nx-os-and-ios-modules/25290/1 "2017-08-18T10:57:09Z")

</div>

Hi there,

I am building a virtual lab to test Ansible network modules against, Cisco Nexus and IOS devices.

I am running ansible with version 2.3.2 on Ubuntu server 16.04.3

root@ubuntu:/etc/ansible# 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.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609]

root@ubuntu:/etc/ansible# lsb\_release -a  
No LSB modules are available.  
Distributor ID: Ubuntu  
Description: Ubuntu 16.04.3 LTS  
Release: 16.04

The playbook that I am running is following:

- hosts: ios  
tasks:
- name: Bring down an interface  
ios\_config:  
lines: no shutdown  
parents: interface {{ item }}  
with\_items:
- Ethernet1/5
- Ethernet1/6
- Ethernet1/7

**Hostfile:**

[all\_routers:children]  
ios  
nexus

[ios]  
Test-IOS-01 ansible\_host=10.10.0.12  
#Test-IOS-02 ansible\_host=10.10.0.13

[nexus]  
Test-Nexus-01 ansible\_host=10.10.0.10 ansible\_port=22  
Test-Nexus-02 ansible\_host=10.10.0.11 ansible\_port=22

[all\_routers:vars]  
ansible\_user=admin  
ansible\_password=admin  
ansible\_connection=local

**Playbook:**

- hosts: ios  
tasks:
- name: Bring down an interface  
ios\_config:  
lines: shutdown  
parents: interface {{ item }}  
match: none  
with\_items:
- Ethernet1/5
- Ethernet1/6
- Ethernet1/7

I have tried several different network modules ( IOS and NEXUS ) against 2 different virtual hosts.

When I run the playbook, I get error everytime on the second loop variable. The first one works always fine.

root@ubuntu:/etc/ansible# ansible-playbook bring\_down\_interface.yaml

PLAY [ios] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [Test-IOS-01]

TASK [Bring down an interface] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [Test-IOS-01] =\> (item=Ethernet1/5)  
failed: [Test-IOS-01] (item=Ethernet1/6) =\> {“failed”: true, “item”: “Ethernet1/6”, “msg”: “unable to open shell. Please see: [https://docs.ansible.com/ansible/network\_debug\_troubleshooting.html#unable-to-open-shell](https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell)”, “rc”: 255}

**with ansible-playbook bring\_down\_interface.yaml -vvvv, I can see**

\<10.10.0.12\> socket\_path: /root/.ansible/pc/74a774a74f  
open\_shell() returned 255 failed to connect to control socket  
failed: [Test-IOS-01] (item=Ethernet1/6) =\> {  
“failed”: true,  
“item”: “Ethernet1/6”,  
“msg”: “unable to open shell. Please see: [https://docs.ansible.com/ansible/network\_debug\_troubleshooting.html#unable-to-open-shell](https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell)”,  
“rc”: 255  
}  
\<10.10.0.12\> using connection plugin network\_cli  
\<10.10.0.12\> socket\_path: /root/.ansible/pc/74a774a74f  
open\_shell() returned 255 failed to connect to control socket  
failed: [Test-IOS-01] (item=Ethernet1/7) =\> {  
“failed”: true,  
“item”: “Ethernet1/7”,  
“msg”: “unable to open shell. Please see: [https://docs.ansible.com/ansible/network\_debug\_troubleshooting.html#unable-to-open-shell](https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell)”,  
“rc”: 255  
}  
to retry, use: --limit @/etc/ansible/bring\_down\_interface.retry

Do you have some ideas how can I fix this matter?

Regards,  
Erotski
