Issue 1:
Issue Type:

Bug Report

Ansible Version:

ansible 1.9.2

configured module search path = None

Ansible Configuration:

# inventory
127.0.0.1

Environment:

CentOS 6.6

Summary:

this issue is similar to #11695

I have the case, that ansible want use ssh connection, if i run ansible-playbook with argument "--connection=local" or "-c local".

If I set in playbook file "connection: local" we have this problem, too.

The only way, how it works is, if we set in inventory file "ansible_connection=local" or if we give an extra argument to ansible-playbook command: "-e ansible_connection=local".

Steps To Reproduce:

---
- name: Test ping on localhost

hosts: localhost
connection: local

tasks:

- name: Ping!
ping:

run: `ansible-playbook -v test.yml`
Remove the line connection: `local from test.yml`
run: `ansible-playbook -v test.yml --connection=local`

Expected Results:

Ansible being able to run locally without the need to have ssh installed.

Actual Results:

Ansible doesn't require ssh when ansible_connection=local is defined in the hosts file.

Ansible requires ssh for a playbook when run with flag --connection=local.

Ansible requires ssh for a playbook when declared connection: local in the playbook.

Issue 2:
Issue Type:

Bug Report

Ansible Version:

ansible 1.9.2

configured module search path = None

Ansible Configuration:

# /etc/ansible/hosts
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python2

Environment:

Archlinux (running ansible locally)

Summary:

Ansible can't run playbooks locally without ssh if ansible_connection=local is defined in the hosts file, although it can run playbooks locally without ssh with connection: local in the playbook or with flag --connection=local.

Steps To Reproduce:

Create test.yml:

---
- name: Test ping on localhost

hosts: localhost
connection: local

tasks:

- name: Ping!
ping:

run: ansible-playbook -v test.yml

Remove the line connection: local from test.yml

run: ansible-playbook -v test.yml --connection=local

Notice that until now it works perfectly fine.

Run ansible-playbook -v test.yml and notice output:

Traceback (most recent call last):
File "/usr/bin/ansible", line 197, in <module>
(runner, results) = cli.run(options, args)
File "/usr/bin/ansible", line 163, in run
extra_vars=extra_vars,
File "/usr/lib/python2.7/site-packages/ansible/runner/__init__.py", line 233, in __init__
cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Install ssh (e.g. on archlinux: pacman -S openssh) and run again the command ansible-playbook -v test.yml. Notice it works again.

Expected Results:

Ansible being able to run locally without the need to have ssh installed.

Actual Results:

Ansible requires ssh when ansible_connection=local is defined in the hosts file.

Ansible doesn't require ssh for a playbook when run with flag --connection=local.

Ansible doesn't require ssh for a playbook when declared connection: local in the playbook.