YAML loop is giving me error: unable to open shell // NX_OS and IOS modules

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”, “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”,
“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”,
“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