# \`ansible -m ping\` does not honor ansible.cfg's remote\_user

**URL:** <https://forum.ansible.com/t/ansible-m-ping-does-not-honor-ansible-cfgs-remote-user/29246>\
**Category:** Ansible Project\
**Tags:** kubernetes\
**Created:** [December 12, 2018, 10:22am UTC](https://forum.ansible.com/t/ansible-m-ping-does-not-honor-ansible-cfgs-remote-user/29246 "2018-12-12T10:22:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [December 12, 2018, 10:22am UTC](https://forum.ansible.com/t/ansible-m-ping-does-not-honor-ansible-cfgs-remote-user/29246/1 "2018-12-12T10:22:36Z")

</div>

Hi all,

Trying to ping a host prepared to accept the ping as a remote user root, I get:

`

$ ansible -m ping master -vvv  
ansible 2.7.4  
config file = /etc/ansible/ansible.cfg  
configured module search path = [‘/home/ydamyanov/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /home/ydamyanov/.venv/ansible/lib/python3.7/site-packages/ansible  
executable location = /home/ydamyanov/.venv/ansible/bin/ansible  
python version = 3.7.1 (default, Oct 20 2018, 21:59:34) [GCC 5.4.0 20160609]  
Using /etc/ansible/ansible.cfg as config file  
/etc/ansible/hosts did not meet host\_list requirements, check plugin documentation if this is unexpected  
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected  
Parsed /etc/ansible/hosts inventory source with ini plugin  
META: ran handlers  
\<10.11.12.13\> ESTABLISH SSH CONNECTION FOR USER: None  
\<10.11.12.13\> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/ydamyanov/.ansible/cp/6f8bec829a 10.11.12.13 ‘/bin/sh -c ‘"’“‘echo ~ && sleep 0’”’"‘’  
\<10.11.12.13\> (255, b’‘, b’Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n’)  
master | UNREACHABLE! =\> {  
“changed”: false,  
“msg”: “Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n”,  
“unreachable”: true  
}

`

which I would expect if I have no remote\_user option set in the config:

`

$ cat /etc/ansible/ansible.cfg  
[global]  
inventory = /etc/ansible/hosts  
remote\_user = root

$ cat /etc/ansible/hosts  
[k8s]

master ansible\_ssh\_host=10.11.12.13

`

If I specify the remote user explicitly on the command line, it works as expected:

`

$ ansible -m ping master -u root  
master | SUCCESS =\> {  
“changed”: false,  
“ping”: “pong”  
}

`

Why does not ansible honor the remote\_user option from the config? Am I missing something?

Thanks for your help!

`

`

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [December 12, 2018, 12:35pm UTC](https://forum.ansible.com/t/ansible-m-ping-does-not-honor-ansible-cfgs-remote-user/29246/2 "2018-12-12T12:35:21Z")

</div>

There is no section called global in ansible.cfg, but you have one called defaults that takes inventory and remote\_user

[https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg#L10](https://github.com/ansible/ansible/blob/devel/examples/ansible.cfg#L10)

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [December 12, 2018, 4:47pm UTC](https://forum.ansible.com/t/ansible-m-ping-does-not-honor-ansible-cfgs-remote-user/29246/3 "2018-12-12T16:47:42Z")

</div>

That was it, Kai, thanks a bunch.

Issuing a warning for such nonsense section names found looks like a good idea to me.

Cheers,  
-YD
