Task fails when using more than one with_items.

40 views
Skip to first unread message

Olof Lundgren

unread,
Jul 14, 2017, 5:19:20 AM7/14/17
to Ansible Project
I have a network module playbook that connect to vyos router and gathers some info. 

---
 
- name: play
    hosts
: vyos
    gather_facts
: no
    connection
: local

    tasks
:
     
- name: vyos facts
        vyos_facts
:
          gather_subset
: "!config"

     
- name: vyos command.
        vyos_command
:
          commands
:
           
- show interfaces ethernet {{ item }}
           
- show version
        with_items
:
         
- eth0
         
- eth1




This is my hosts file:

[vyos]
router1
router2

[vyos:vars]
ansible_user
=vyos
ansible_ssh_pass
=password



When I run the playbook, I get all the info from vyos_facts and vyos_command show interface ethernet eth0
But when it comes to {{ eth1 }} it fails with this message. 
It doesnt continue to the show version part at all. 
$ ansible-playbook vyos.yml
....
failed
: [router1] (item=eth1) => {
   
"failed": true,
   
"item": "eth1",
   
"msg": "unable to open shell. Please see: https://docs.ansible.com/ansible/network_debug_troubleshooting.html#unable-to-open-shell",
   
"rc": 255
}
...



However, if I define the username and password under vyos_command it succeeds...
---
 
- name: play
    hosts
: vyos
    gather_facts
: no
    connection
: local

    tasks
:
     
- name: vyos facts
        vyos_facts
:
          gather_subset
: "!config"

     
- name: vyos command.
        vyos_command
:
          commands
:
           
- show interfaces ethernet {{ item }}
           
- show version
          username
: vyos
          password
: password
        with_items
:
         
- eth0
         
- eth1




My version:

$ ansible --version
ansible
2.3.1.0


Reply all
Reply to author
Forward
0 new messages