Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localhost unreachable on Windows Subsystem for Linux (WSL2, Ubuntu) #69765

Closed
lilvyao opened this issue May 29, 2020 · 6 comments
Closed

Localhost unreachable on Windows Subsystem for Linux (WSL2, Ubuntu) #69765

lilvyao opened this issue May 29, 2020 · 6 comments
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@lilvyao
Copy link

lilvyao commented May 29, 2020

SUMMARY

Unable to establish connection to localhost under Windows Subsystem for Linux (WSL, Ubuntu)

ISSUE TYPE
  • Bug Report
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
  1. Update ansible.cfg, set remote_tmp to "/tmp"
  2. Reinstalled SSHD and enable ssh on WSL
  3. Tried reinstalling different versions of Ansible (2.5.X - 2.9.X)
OBSERVATIONS
  1. I am able to ssh into localhost from local
  2. The command works fine when running inside a docker container
@ansibot
Copy link
Contributor

ansibot commented May 29, 2020

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels May 29, 2020
@gefela
Copy link

gefela commented May 30, 2020

COMPONENT
lib/ansible/module_utils/common/network.py incorrect

@ilukinov
Copy link

ilukinov commented Jun 1, 2020

having exact same issue, expecting it to run locally without any ssh connection but getting this error

@jborean93
Copy link
Contributor

Is This A Bug?

Hi!

Thanks very much for your submission to Ansible. It sincerely means a lot to us.

We're not sure this is a bug, and we don't mean for this to be confrontational. Let's explain what we're thinking:

  • Ansible just calls ssh for ssh connections so you can run with -vvv to see the exact calls that are happening. From there you can run it manually to see why the auth failed
  • If you are connecting to localhost you shouldn't even need to use ssh, just make sure ansible_connection=local is set in your inventory for your localhost entry
  • If you don't have localhost defined then it should use local by default, if you don't think you have it defined but it's using SSH then it's either defined somewhere you don't know about or you've set connection: ssh or ansible_connection: ssh somewhere

As such, we're going to close this ticket. However, we're open to being corrected, should you wish to discuss. You can stop by one of our two mailing lists
to talk about this and we might be persuaded otherwise.

Comments on closed tickets aren't something we monitor, so if you do disagree with this, a mailing list thread is probably appropriate.

Thank you once again for this and your interest in Ansible!

@lilvyao
Copy link
Author

lilvyao commented Jun 2, 2020

(Re-posting the solutions I shared in the Google Groups. Hope this helps whoever encountered the same problem)

Thanks For pointing the direction Jordan!

I was able to solve the problem by installing libc6_2.31 on my WSL Ubuntu. The steps are as following:
Download libc6_2.31-0ubuntu9_amd64.deb.zip
mv libc6_2.31-0ubuntu9_amd64.deb.zip libc6_2.31-0ubuntu9_amd64.deb
sudo dpkg -i libc6_2.31-0ubuntu9_amd64.deb

When I ran "ansible localhost -m ping" again, I was able to get the following:

localhost | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}

As Jordan mentioned, this is a problem on the WSL side rather than Ansible itself. Hope the above helps whoever encountered the same problem.

@samdoran samdoran removed the needs_triage Needs a first human triage before being processed. label Jun 2, 2020
@karjona
Copy link

karjona commented Jun 3, 2020

Proposed solution also solved the issue for me: Windows 10 2004, WSL2, Ubuntu 20.04.
Definitely a WSL issue, not an Ansible one. This is the direct link to the Google Group where you can download the package mentioned in the previous post: https://groups.google.com/d/msg/ansible-project/GDYC2F1K8pk/4Z1rAeb_AQAJ

@ansible ansible locked and limited conversation to collaborators Jun 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

7 participants