`ansible -m ping` does not honor ansible.cfg's remote_user

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!

`

`

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

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