<p dir="auto">I put ansible_ssh_user in inventory, to cope with the fact that new instances in our cloud demand login with different users, depending on distro (root, cirros, debian, etc.)  But this overrides remote_user in playbooks.</p>
<p dir="auto">I mentioned this issue on #ansible, and <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/jctanner/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/jctanner">@jctanner</a> asked me to file a bug for it. Not a big deal for me, because I have a workaround (which is to use sudo_user instead of remote_user).</p>
<h1 dir="auto">How to repeat</h1>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="cat &gt; ansible_hosts &lt;&lt; EOF
[demo]
localhost

[demo:vars]
ansible_ssh_user=root
EOF

cat &gt; demo-bug.yml &lt;&lt; EOF

---
- hosts: demo
  remote_user: $LOGNAME
  tasks:
    - name: Echo remote user
      shell: echo \$LOGNAME
    - name: Prove that remote user is $LOGNAME
      shell: test \$LOGNAME = sheldonh
EOF

ansible-playbook -i ansible_hosts demo-bug.yml -v"><pre class="notranslate">cat <span class="pl-k">&gt;</span> ansible_hosts <span class="pl-s"><span class="pl-k">&lt;&lt;</span> <span class="pl-k">EOF</span></span>
<span class="pl-s">[demo]</span>
<span class="pl-s">localhost</span>
<span class="pl-s"></span>
<span class="pl-s">[demo:vars]</span>
<span class="pl-s">ansible_ssh_user=root</span>
<span class="pl-s"><span class="pl-k">EOF</span></span>

cat <span class="pl-k">&gt;</span> demo-bug.yml <span class="pl-s"><span class="pl-k">&lt;&lt;</span> <span class="pl-k">EOF</span></span>
<span class="pl-s"></span>
<span class="pl-s">---</span>
<span class="pl-s">- hosts: demo</span>
<span class="pl-s">  remote_user: <span class="pl-smi">$LOGNAME</span></span>
<span class="pl-s">  tasks:</span>
<span class="pl-s">    - name: Echo remote user</span>
<span class="pl-s">      shell: echo <span class="pl-cce">\$</span>LOGNAME</span>
<span class="pl-s">    - name: Prove that remote user is <span class="pl-smi">$LOGNAME</span></span>
<span class="pl-s">      shell: test <span class="pl-cce">\$</span>LOGNAME = sheldonh</span>
<span class="pl-s"><span class="pl-k">EOF</span></span>

ansible-playbook -i ansible_hosts demo-bug.yml -v</pre></div>
<p dir="auto">Note that the second task fails, because the remote_user was ignored in favour of root (which you can see proven in the verbose output of the first task.</p>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible --version
ansible 2.2.0 (devel 3121e352f7) last updated 2016/06/03 14:30:49 (GMT -500)
  lib/ansible/modules/core: (detached HEAD 2bd8d78a8b) last updated 2016/06/03 14:30:49 (GMT -500)
  lib/ansible/modules/extras: (detached HEAD b0aec50b9a) last updated 2016/06/01 14:41:34 (GMT -500)
  config file = /Users/tanner/projects/ansible.git/playbooks.git/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible --version
ansible 2.2.0 (devel 3121e352f7) last updated 2016/06/03 14:30:49 (GMT -500)
  lib/ansible/modules/core: (detached HEAD 2bd8d78a8b) last updated 2016/06/03 14:30:49 (GMT -500)
  lib/ansible/modules/extras: (detached HEAD b0aec50b9a) last updated 2016/06/01 14:41:34 (GMT -500)
  config file = /Users/tanner/projects/ansible.git/playbooks.git/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">No changes to the ansible.cfg or environment variables</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Running from OS X 10.11.5<br>
Managing: N/A</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Attempting to get Ansible working with Windows.<br>
A simple inventory files and a very simple playbook with a very simple task fails to load with the error message: "ERROR! Unexpected Exception: need more than 1 value to unpack"</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<p dir="auto">Inventory file testing-windows</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[windows-workstations]
winvm1.tanners.org
winvm2.tanners.org
winvm3.tanners.org
winvm4.tanners.org
winvm5.tanners.org"><pre class="notranslate"><code class="notranslate">[windows-workstations]
winvm1.tanners.org
winvm2.tanners.org
winvm3.tanners.org
winvm4.tanners.org
winvm5.tanners.org
</code></pre></div>
<p dir="auto">Playbook windows-workstations.yml</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
---
# file: windows-workstations.yml

- hosts: windows-workstations
  vars:
  pre_tasks:
  roles:
  tasks:
  post_tasks:"><pre class="notranslate"><code class="notranslate">
---
# file: windows-workstations.yml

- hosts: windows-workstations
  vars:
  pre_tasks:
  roles:
  tasks:
  post_tasks:
</code></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">Playbook would load and do nothing</p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ansible-playbook -i testing-windows  windows-workstations.yml  -vvv
Using /Users/tanner/projects/ansible.git/playbooks.git/ansible.cfg as config file
ERROR! Unexpected Exception: need more than 1 value to unpack
the full traceback was:

Traceback (most recent call last):
  File &quot;/Users/tanner/projects/ansible.git/ansible/bin/ansible-playbook&quot;, line 97, in &lt;module&gt;
    exit_code = cli.run()
  File &quot;/Users/tanner/projects/ansible.git/ansible/lib/ansible/cli/playbook.py&quot;, line 154, in run
    results = pbex.run()
  File &quot;/Users/tanner/projects/ansible.git/ansible/lib/ansible/executor/playbook_executor.py&quot;, line 73, in run
    self._inventory.set_playbook_basedir(os.path.dirname(playbook_path))
  File &quot;/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py&quot;, line 697, in set_playbook_basedir
    self.get_group_vars(group)
  File &quot;/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py&quot;, line 715, in get_group_vars
    return self._get_hostgroup_vars(host=None, group=group, new_pb_basedir=new_pb_basedir)
  File &quot;/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py&quot;, line 776, in _get_hostgroup_vars
    self._variable_manager.add_group_vars_file(base_path, self._loader)
  File &quot;/Users/tanner/projects/ansible.git/ansible/lib/ansible/vars/__init__.py&quot;, line 602, in add_group_vars_file
    data = self._load_inventory_file(path, loader)
  File &quot;/Users/tanner/projects/ansible.git/ansible/lib/ansible/vars/__init__.py&quot;, line 540, in _load_inventory_file
    _found, results = self._load_inventory_file(path=p, loader=loader)
ValueError: need more than 1 value to unpack"><pre class="notranslate"><code class="notranslate">$ ansible-playbook -i testing-windows  windows-workstations.yml  -vvv
Using /Users/tanner/projects/ansible.git/playbooks.git/ansible.cfg as config file
ERROR! Unexpected Exception: need more than 1 value to unpack
the full traceback was:

Traceback (most recent call last):
  File "/Users/tanner/projects/ansible.git/ansible/bin/ansible-playbook", line 97, in &lt;module&gt;
    exit_code = cli.run()
  File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/cli/playbook.py", line 154, in run
    results = pbex.run()
  File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/executor/playbook_executor.py", line 73, in run
    self._inventory.set_playbook_basedir(os.path.dirname(playbook_path))
  File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py", line 697, in set_playbook_basedir
    self.get_group_vars(group)
  File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py", line 715, in get_group_vars
    return self._get_hostgroup_vars(host=None, group=group, new_pb_basedir=new_pb_basedir)
  File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/inventory/__init__.py", line 776, in _get_hostgroup_vars
    self._variable_manager.add_group_vars_file(base_path, self._loader)
  File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/vars/__init__.py", line 602, in add_group_vars_file
    data = self._load_inventory_file(path, loader)
  File "/Users/tanner/projects/ansible.git/ansible/lib/ansible/vars/__init__.py", line 540, in _load_inventory_file
    _found, results = self._load_inventory_file(path=p, loader=loader)
ValueError: need more than 1 value to unpack
</code></pre></div>