SUMMARY
Unable to establish connection to localhost under Windows Subsystem for Linux (WSL, Ubuntu)
ISSUE TYPE
COMPONENT NAME
Network
ANSIBLE VERSION
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0]
CONFIGURATION
DEFAULT_LOCAL_TMP(/etc/ansible/ansible.cfg) = /tmp/ansible-local-2309_h96pb5
OS / ENVIRONMENT
OS:
OS Name: Microsoft Windows 10 Pro (Version 1909)
OS Version: 10.0.18363 N/A Build 18363
WSL:
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
STEPS TO REPRODUCE
Run this command:
ansible localhost -m ping
EXPECTED RESULTS
The ping request successfully poerformed, and Ansible returns the following:
localhost | SUCCESS => {
"changed": false,
"ping": "pong"
}
ACTUAL RESULTS
The ping request failed. The following error returned:
localhost | UNREACHABLE! => {
"changed": false,
"msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo /tmp/ansible-tmp-1590770997.3577683-86430694066473 `\" && echo ansible-tmp-1590770997.3577683-86430694066473=\"` echo /tmp/ansible-tmp-1590770997.3577683-86430694066473 `\" ), exited with result 1, stdout output: ansible-tmp-1590770997.3577683-86430694066473=/tmp/ansible-tmp-1590770997.3577683-86430694066473\n",
"unreachable": true
}
TROUBLESHOOT ACTIONS TAKEN SO FAR
- Update ansible.cfg, set remote_tmp to "/tmp"
- Reinstalled SSHD and enable ssh on WSL
- Tried reinstalling different versions of Ansible (2.5.X - 2.9.X)
- Tried setting the connection to local in host file as suggested (new)
- Tried force local connection from ansible-playbook command (new)
OBSERVATIONS
- I am able to ssh into localhost from local
- The command works fine when running inside a docker container
---------------------------------detail output-----------------------------------
root@leoli:/mnt/c/Users/leoli# ansible localhost -vvvv -m ping
ansible 2.9.6
config file = /etc/ansible/ansible.cfg
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Set default localhost to localhost
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading callback plugin minimal of type stdout, v2.0 from /usr/lib/python3/dist-packages/ansible/plugins/callback/minimal.py
META: ran handlers
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1591053120.0766757-250645184932946 `" && echo ansible-tmp-1591053120.0766757-250645184932946="` echo /tmp/ansible-tmp-1591053120.0766757-250645184932946 `" ) && sleep 0'
localhost | UNREACHABLE! => {
"changed": false,
"msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo /tmp/ansible-tmp-1591053120.0766757-250645184932946 `\" && echo ansible-tmp-1591053120.0766757-250645184932946=\"` echo /tmp/ansible-tmp-1591053120.0766757-250645184932946 `\" ), exited with result 1, stdout output: ansible-tmp-1591053120.0766757-250645184932946=/tmp/ansible-tmp-1591053120.0766757-250645184932946\n, stderr output: sleep: cannot read realtime clock: Invalid argument\n",
"unreachable": true
}