<h5 dir="auto">Issue Type:</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.9.2<br>
configured module search path = None</p>
<h5 dir="auto">Ansible Configuration:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# inventory
127.0.0.1 "><pre class="notranslate"><code class="notranslate"># inventory
127.0.0.1 
</code></pre></div>
<h5 dir="auto">Environment:</h5>
<p dir="auto">CentOS 6.6</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">this issue is similar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="96566374" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/11695" data-hovercard-type="issue" data-hovercard-url="/ansible/ansible/issues/11695/hovercard" href="https://github.com/ansible/ansible/issues/11695">#11695</a></p>
<p dir="auto">I have the case, that ansible want use ssh connection, if i run ansible-playbook with argument <code class="notranslate">"--connection=local"</code> or <code class="notranslate">"-c local"</code>.<br>
If I set in playbook file <code class="notranslate">"connection: local"</code> we have this problem, too.</p>
<p dir="auto">The only way, how it works is, if we set in inventory file <code class="notranslate">"ansible_connection=local"</code> or if we give an extra argument to ansible-playbook command: <code class="notranslate">"-e ansible_connection=local"</code>.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- name: Test ping on localhost

  hosts: localhost
  connection: local

  tasks:

  - name: Ping!
    ping:"><pre class="notranslate"><code class="notranslate">
---
- name: Test ping on localhost

  hosts: localhost
  connection: local

  tasks:

  - name: Ping!
    ping:
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="run: `ansible-playbook -v test.yml`
Remove the line connection: `local from test.yml`
run: `ansible-playbook -v test.yml --connection=local`"><pre class="notranslate"><code class="notranslate">run: `ansible-playbook -v test.yml`
Remove the line connection: `local from test.yml`
run: `ansible-playbook -v test.yml --connection=local`
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Ansible being able to run locally without the need to have ssh installed.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">Ansible doesn't require ssh when ansible_connection=local is defined in the hosts file.<br>
Ansible requires ssh for a playbook when run with flag --connection=local.<br>
Ansible requires ssh for a playbook when declared connection: local in the playbook.</p>
<h5 dir="auto">Issue Type:</h5>
<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">ansible 1.9.2<br>
configured module search path = None</p>
<h5 dir="auto">Ansible Configuration:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# /etc/ansible/hosts
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python2"><pre class="notranslate"><code class="notranslate"># /etc/ansible/hosts
localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python2
</code></pre></div>
<h5 dir="auto">Environment:</h5>
<p dir="auto">Archlinux (running ansible locally)</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Ansible can't run playbooks locally without ssh if <code class="notranslate">ansible_connection=local</code> is defined in the hosts file, although it can run playbooks locally without ssh with <code class="notranslate">connection: local</code> in the playbook or with flag <code class="notranslate">--connection=local</code>.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<ul dir="auto">
<li>Create <code class="notranslate">test.yml</code>:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
- name: Test ping on localhost

  hosts: localhost
  connection: local

  tasks:

  - name: Ping!
    ping:"><pre class="notranslate"><code class="notranslate">
---
- name: Test ping on localhost

  hosts: localhost
  connection: local

  tasks:

  - name: Ping!
    ping:
</code></pre></div>
<ul dir="auto">
<li>run: <code class="notranslate">ansible-playbook -v test.yml</code></li>
<li>Remove the line <code class="notranslate">connection: local</code> from <code class="notranslate">test.yml</code></li>
<li>run: <code class="notranslate">ansible-playbook -v test.yml --connection=local</code></li>
</ul>
<p dir="auto">Notice that until now it works perfectly fine.</p>
<ul dir="auto">
<li>Run <code class="notranslate">ansible-playbook -v test.yml</code> and notice output:</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/usr/bin/ansible&quot;, line 197, in &lt;module&gt;
    (runner, results) = cli.run(options, args)
  File &quot;/usr/bin/ansible&quot;, line 163, in run
    extra_vars=extra_vars,
  File &quot;/usr/lib/python2.7/site-packages/ansible/runner/__init__.py&quot;, line 233, in __init__
    cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File &quot;/usr/lib/python2.7/subprocess.py&quot;, line 710, in __init__
    errread, errwrite)
  File &quot;/usr/lib/python2.7/subprocess.py&quot;, line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/usr/bin/ansible", line 197, in &lt;module&gt;
    (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
</code></pre></div>
<ul dir="auto">
<li>Install <code class="notranslate">ssh</code> (e.g. on archlinux: <code class="notranslate">pacman -S openssh</code>) and run again the command <code class="notranslate">ansible-playbook -v test.yml</code>. Notice it works again.</li>
</ul>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">Ansible being able to run locally without the need to have ssh installed.</p>
<h5 dir="auto">Actual Results:</h5>
<p dir="auto">Ansible <strong>requires ssh</strong> when <code class="notranslate">ansible_connection=local</code> is defined in the hosts file.<br>
Ansible <strong>doesn't require ssh</strong> for a playbook when run with flag <code class="notranslate">--connection=local</code>.<br>
Ansible <strong>doesn't require ssh</strong> for a playbook when declared <code class="notranslate">connection: local</code> in the playbook.</p>