# Not understanding why getting a failure on a task with "remote\_user" set

**URL:** <https://forum.ansible.com/t/not-understanding-why-getting-a-failure-on-a-task-with-remote-user-set/18098>\
**Category:** Ansible Project\
**Created:** [April 27, 2015, 9:48pm UTC](https://forum.ansible.com/t/not-understanding-why-getting-a-failure-on-a-task-with-remote-user-set/18098 "2015-04-27T21:48:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [April 27, 2015, 9:48pm UTC](https://forum.ansible.com/t/not-understanding-why-getting-a-failure-on-a-task-with-remote-user-set/18098/1 "2015-04-27T21:48:37Z")

</div>

Hi all,

The section of the playbook that I am experiencing a failure (authenication failure) on is as follows:

`

- name: Enable passwordless connection as hdfs user to namenode host  
authorized\_key: user=hdfs key=“{{ lookup(‘file’, ‘~/.ssh/id\_rsa.pub’) }}”  
when: action == “format\_hdfs” and “{{ ansible\_hostname }}” in “{{ groups[‘hadoop\_namenodes’] }}”  
tags: formathdfs

- name: Format HDFS on namenode  
remote\_user: hdfs  
shell: source ~/.profile && {{ install\_directory }}/hadoop/bin/hdfs namenode -format -force  
args:  
executable: /bin/bash  
when: action == “format\_hdfs” and “{{ ansible\_hostname }}” in “{{ groups[‘hadoop\_namenodes’] }}”  
tags: formathdfs

`

When I run the playbook as ‘root’ I get a failure, even though I have set the failing task’s “remote\_user” to the appropriate user, and have (in the prior task) done a SSH key exchange for that user…

`  
ansible-playbook -u root -k -i test hadoop-site.yml --tags=formathdfs --limit=hadoop-test1  
[…]  
PLAY [hadoop\_namenodes] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [hadoop-test1]

TASK: [do-hadoop | Enable passwordless connection as hdfs user to namenode host] \*\*\*  
ok: [hadoop-test1]

TASK: [do-hadoop | Format HDFS on namenode] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [hadoop-test1] =\> Authentication failure.

FATAL: all hosts have already failed – aborting

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
to retry, use: --limit @/home/will/hadoop-site.retry

hadoop-test1 : ok=4 changed=0 unreachable=1 failed=0

`

However, if I run playbook as the user that needs to perform the failing step (‘hdfs’), it works…

`  
ansible-playbook -u hdfs -i test hadoop-site.yml --tags=formathdfs --limit=hadoop-test1  
[…]  
PLAY [hadoop\_namenodes] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

GATHERING FACTS \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [hadoop-test1]

TASK: [do-hadoop | Enable passwordless connection as hdfs user to namenode host] \*\*\*  
ok: [hadoop-test1]

TASK: [do-hadoop | Format HDFS on namenode] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [hadoop-test1]

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
hadoop-test1 : ok=5 changed=1 unreachable=0 failed=0

`

Can someone explain to me why the first case is failing, and how I could get it to work?

Thanks,  
Will

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 27, 2015, 9:59pm UTC](https://forum.ansible.com/t/not-understanding-why-getting-a-failure-on-a-task-with-remote-user-set/18098/2 "2015-04-27T21:59:08Z")

</div>

The issue is not remote user it is that you are mixing key based and  
password based authentication, for hdfs you have a key, but for root  
you use a password. These don't mix in the same run and you should  
have both users either use keys or passwords.

---

<div class="post-metadata">

**Author:** ![Will\_Dennis](https://avatars.discourse-cdn.com/v4/letter/w/919ad9/32.png) [@Will\_Dennis](https://forum.ansible.com/u/Will_Dennis)\
**Post date:** [April 27, 2015, 11:55pm UTC](https://forum.ansible.com/t/not-understanding-why-getting-a-failure-on-a-task-with-remote-user-set/18098/3 "2015-04-27T23:55:00Z")

</div>

Thanks Brian, make sense… Will do a key exchange for the root account as well.

Best,  
Will

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 28, 2015, 12:02am UTC](https://forum.ansible.com/t/not-understanding-why-getting-a-failure-on-a-task-with-remote-user-set/18098/4 "2015-04-28T00:02:39Z")

</div>

Or you can just have them as separate plays, right now ansible will  
see -k on the command line and expect all connections to prompt for  
password, we might want to make this behavior overridable but not sure  
how well this can work (though IIRC we do have the inventory var  
ansible\_ssh\_pass that can provide this by host).
