# v2 bug, \`connection: local\` not honoured

**URL:** <https://forum.ansible.com/t/v2-bug-connection-local-not-honoured/17525>\
**Category:** Ansible Developer\
**Created:** [February 16, 2015, 3:04pm UTC](https://forum.ansible.com/t/v2-bug-connection-local-not-honoured/17525 "2015-02-16T15:04:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 16, 2015, 3:04pm UTC](https://forum.ansible.com/t/v2-bug-connection-local-not-honoured/17525/1 "2015-02-16T15:04:59Z")

</div>

Hi, FYI,

I was playing with v2, and noticed the following in ansible/v2/samples/test\_block.yml:

That playbook contains a connection: local, but connection still goes over ssh.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [February 16, 2015, 5:47pm UTC](https://forum.ansible.com/t/v2-bug-connection-local-not-honoured/17525/2 "2015-02-16T17:47:22Z")

</div>

I think this is happening because utils.cli.base\_parser() defaults the  
connection option to 'smart' in v2.

Try commenting out the default in utils/cli.py (line 101):

&nbsp;&nbsp;&nbsp;&nbsp;if connect\_opts:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;parser.add\_option('-c', '--connection', dest='connection',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#default=C.DEFAULT\_TRANSPORT,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;help="connection type to use (default=%s)" %  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C.DEFAULT\_TRANSPORT)

There is a FIXME comment in TaskExecutor.\_get\_connection, so I'm  
guessing the 'smart' logic is not fully developed (as it's defaulting to  
'ssh').

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if conn\_type == 'smart':  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;conn\_type = 'ssh'

Interestingly, if you omit ansible\_connection=local for localhost in the  
inventory file, Inventory.\_create\_implicit\_localhost() will set it for  
you.

Giovanni

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [February 18, 2015, 3:39pm UTC](https://forum.ansible.com/t/v2-bug-connection-local-not-honoured/17525/3 "2015-02-18T15:39:14Z")

</div>

Yes, this has been a minor annoyance I’ve been meaning to fix for a while, just somewhat lower on the list of V2 bugs. Feel free to send in a patch in the meantime.

---

<div class="post-metadata">

**Author:** ![senorsmile](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/senorsmile/32/9024_2.png) [@senorsmile](https://forum.ansible.com/u/senorsmile)\
**Post date:** [September 23, 2015, 10:24pm UTC](https://forum.ansible.com/t/v2-bug-connection-local-not-honoured/17525/4 "2015-09-23T22:24:20Z")

</div>

This appears to still be an issue (with current devel branch).

A connection: local on a block isn’t honored, exactly as op described.
