Open robertdebock opened 2 years ago
I did habe troubles with underscores in hostnames before. According to RFC 952 underscores are not valid, and I think that some versions of linux (glibc?) follow that more strictly than others.
A "name" (Net, Host, Gateway, or Domain name) is a text string up
to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus
sign (-), and period (.).
That said, I am not sure that the issue is caused by molecule.
That said, I am not sure that the issue is caused by molecule.
I agree, it's not really molecule, on the other hand, I would not know how to proceed with it now...
FWIW, I managed to trigger the sudo error without using molecule. It happens when there is no entry in /etc/hosts in the container.
I created my test container with podman run --no-hosts ...
-> /etc/hosts does not exist at all, and after installing python and sudo and creating a user, when connecting there is the sudo: unable to resolve host ...
errror. After creating an entry in /etc/hosts ansible connection was working.
I found a blog post about this topic https://linuxhandbook.com/sudo-unable-resolve-host/
Thanks @mafalb, I am seeing this issue;
_
./etc/hosts
is with _
.Have a look at a Docker instance that Molecule created:
root@pythonpip-debian-bookworm:/# cat /etc/hosts
# (non relevant lines removed)
172.17.0.6 python_pip-debian-bookworm
root@pythonpip-debian-bookworm:/# hostname
pythonpip-debian-bookworm
I wonder if Molecule can "fix" this as I'm not sure what sets the hostname.
For now, I'll remove the underscores from molecule/default/molecule.yml
: platforms.name
.
For future readers, this is BROKEN:
platforms:
- name: "some_name" # BROKEN, an underscore can give issues with setting the hostname.
This is WORKING:
platforms:
- name: "somename"
HAPPY NEW YEAR! And thanks for making and maintaining Molecule. My wished for 2022: Keep up the exceptional work!
Issue Type
Molecule and Ansible details
Molecule installation method (one of):
Ansible installation method (one of):
Detail any linters or test runners used:
Desired Behaviour
Some roles have an underscore
_
in the name, likeansible-role-python_pip
. Molecule should not change the hostname, I think it does.Actual Behaviour
Molecule removes the
_
from the hostname. This can cause an issue withsudo
:(So far, only
debian:bookworm
causes an issue, I guess the sudo is configured a bit more strict.)This behaviour seems new, I checked the last few molecule releases, but could not find a related change. This makes me unsure if Molecule causes the issue or Debian (or
sudo
), so please let me know if you think it's something different than Molecule that causes the removal of the_
from the hostname.(The full error.)
Reproduction