<h5 dir="auto">Issue Type: Bug Report</h5>
<h5 dir="auto">Ansible Version: 1.5.5, 1.6.10, 1.7.1</h5>
<h5 dir="auto">Environment: Ubuntu 12.04 -&gt; Ubuntu 12.04</h5>
<h5 dir="auto">Summary:</h5>
<p dir="auto">The ansible_ssh_user setting does not appear to be applied to a host when using the delegate_to feature.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">test inventory:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[lb]
lb ansible_ssh_user=ubuntu

[web]
web ansible_ssh_user=ubuntu"><pre class="notranslate"><code class="notranslate">[lb]
lb ansible_ssh_user=ubuntu

[web]
web ansible_ssh_user=ubuntu
</code></pre></div>
<p dir="auto">test.yml playbook:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
---

- hosts: web
  serial: 1
  sudo: yes

  tasks:
    - name: this is a test
      shell: echo test
      delegate_to: lb"><pre class="notranslate">---

- <span class="pl-ent">hosts</span>: <span class="pl-s">web</span>
  <span class="pl-ent">serial</span>: <span class="pl-c1">1</span>
  <span class="pl-ent">sudo</span>: <span class="pl-s">yes</span>

  <span class="pl-ent">tasks</span>:
    - <span class="pl-ent">name</span>: <span class="pl-s">this is a test</span>
      <span class="pl-ent">shell</span>: <span class="pl-s">echo test</span>
      <span class="pl-ent">delegate_to</span>: <span class="pl-s">lb</span></pre></div>
<p dir="auto">run ansible:<br>
<code class="notranslate">ansible-playbook -i test test.yml -vvvv</code></p>
<h5 dir="auto">Expected Results:</h5>
<p dir="auto">I expect that it would use the ssh user defined by the ansible_ssh_user setting when attempting to log into the lb node.</p>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK: [this is a test] ******************************************************** 
&lt;lb&gt; ESTABLISH CONNECTION FOR USER: user
&lt;lb&gt; REMOTE_MODULE command echo test #USE_SHELL
&lt;lb&gt; EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'lb', &quot;/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1410482613.68-50435724199494 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1410482613.68-50435724199494 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1410482613.68-50435724199494'&quot;]"><pre class="notranslate"><code class="notranslate">TASK: [this is a test] ******************************************************** 
&lt;lb&gt; ESTABLISH CONNECTION FOR USER: user
&lt;lb&gt; REMOTE_MODULE command echo test #USE_SHELL
&lt;lb&gt; EXEC ['ssh', '-C', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'lb', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1410482613.68-50435724199494 &amp;&amp; chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1410482613.68-50435724199494 &amp;&amp; echo $HOME/.ansible/tmp/ansible-tmp-1410482613.68-50435724199494'"]
</code></pre></div>
<p dir="auto">Comparing this to the ssh command used on tasks that aren't delegated, it's missing the <code class="notranslate">-o User=ubuntu</code> section of the command.</p>
<h5 dir="auto">Issue Type:</h5>
<p dir="auto">Bug Report</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto">1.6.6<br>
ansible-playbook 1.7 (devel <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/8e940004c2f940fc01eacaf2c403cc2fab61f722/hovercard" href="https://github.com/ansible/ansible/commit/8e940004c2f940fc01eacaf2c403cc2fab61f722"><tt>8e94000</tt></a>) last updated 2014/07/21 13:14:41 (GMT -400)</p>
<h5 dir="auto">Environment:</h5>
<p dir="auto">OSX Mavericks</p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Delegating a task should accept that delegated host's ansible_ssh_user variable. Instead it returns the currently logged in user.</p>
<h5 dir="auto">Steps To Reproduce:</h5>
<p dir="auto">inventory:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[host1]
127.0.0.1 ansible_ssh_user=foo

[host2]
127.0.0.2 ansible_ssh_user=bar"><pre class="notranslate"><code class="notranslate">[host1]
127.0.0.1 ansible_ssh_user=foo

[host2]
127.0.0.2 ansible_ssh_user=bar
</code></pre></div>
<p dir="auto">playbook:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="- hosts: host1
  connection: local
  tasks:
  - debug: var=ansible_ssh_user
    delegate_to: host2"><pre class="notranslate"><code class="notranslate">- hosts: host1
  connection: local
  tasks:
  - debug: var=ansible_ssh_user
    delegate_to: host2
</code></pre></div>
<h5 dir="auto">Expected Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [host1] ******************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug var=ansible_ssh_user] ********************************************
ok: [127.0.0.1] =&gt; {
    &quot;ansible_ssh_user&quot;: &quot;bar&quot;
}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">PLAY [host1] ******************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug var=ansible_ssh_user] ********************************************
ok: [127.0.0.1] =&gt; {
    "ansible_ssh_user": "bar"
}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0
</code></pre></div>
<h5 dir="auto">Actual Results:</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAY [host1] ******************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug var=ansible_ssh_user] ********************************************
ok: [127.0.0.1] =&gt; {
    &quot;ansible_ssh_user&quot;: &quot;jmartin&quot;
}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0"><pre class="notranslate"><code class="notranslate">PLAY [host1] ******************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [debug var=ansible_ssh_user] ********************************************
ok: [127.0.0.1] =&gt; {
    "ansible_ssh_user": "jmartin"
}

PLAY RECAP ********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0
</code></pre></div>