v2 bug, `connection: local` not honoured

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.

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):

    if connect_opts:
        parser.add_option('-c', '--connection', dest='connection',
                          #default=C.DEFAULT_TRANSPORT,
                          help="connection type to use (default=%s)" %
                          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').

        if conn_type == 'smart':
            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

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.

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

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