# Ansible Tower Playbook issue: need to limit SSH connections to specific Cisco switch hosts within each task

**URL:** <https://forum.ansible.com/t/ansible-tower-playbook-issue-need-to-limit-ssh-connections-to-specific-cisco-switch-hosts-within-each-task/25465>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [September 12, 2017, 5:27pm UTC](https://forum.ansible.com/t/ansible-tower-playbook-issue-need-to-limit-ssh-connections-to-specific-cisco-switch-hosts-within-each-task/25465 "2017-09-12T17:27:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark.kleinhaus](https://avatars.discourse-cdn.com/v4/letter/m/8e7dd6/32.png) [@mark.kleinhaus](https://forum.ansible.com/u/mark.kleinhaus)\
**Post date:** [September 12, 2017, 5:27pm UTC](https://forum.ansible.com/t/ansible-tower-playbook-issue-need-to-limit-ssh-connections-to-specific-cisco-switch-hosts-within-each-task/25465/1 "2017-09-12T17:27:12Z")

</div>

I’m new to Ansible Automation and hopefully this is a simple fix-

Running Ansible Tower 2.4.4 on Windows Server 2012 R2.  
I’m using the ios\_command and ios\_config modules.

I have a group called “XYZ” that contains hosts “1.1.1.1” and “2.2.2.2”. I want each task in the playbook to only attempt SSH to a specific host within the group.

Here’s the problem:  
-The playbook will attempt to SSH to all hosts in the group by default on the first task. It will succeed on the first host specified with vars, but fail on every host after, even if I’m passing through the creds correctly.  
-I need to set “connection”: to “local” for the ios\_command, and ios\_config modules to work. However if I try to use the “delegate\_to” command, it fails because it wants to SSH but sees the connection as local.

Is there any way to limit the playbook connections to a specific host within each task? I don’t want to create a separate playbook for each host, and I don’t want to create a separate group for each host within Ansible Tower.

Sample config:

- name: XYZ SSH Test  
hosts: XYZ  
connection: local  
gather\_facts: false  
vars:  
1Switch:  
host: “1.1.1.1”  
username: “{{1user}}”  
password: “{{1pass}}”  
timeout: 60  
2Switch:  
host: “2.2.2.2”  
username: “{{2user}}”  
password: “{{2pass}}”  
timeout: 60  
tasks:  
#get an interface on 1.1.1.1
- name: Get 1.1.1.1 interface status  
run\_once: true  
delegate\_to: 1.1.1.1  
ios\_command:  
commands: show interface gi1/0/1  
provider: “{{ 1Switch }}”  
register: gi1\_0\_1  
#get an interface on 2.2.2.2
- name: Get 2.2.2.2 interface status  
run\_once: true  
delegate\_to: 2.2.2.2  
ios\_command:  
commands: show interface Gig 2/0/2  
provider: “{{ 2Switch }}”  
register: gi2\_0\_2
