-
Notifications
You must be signed in to change notification settings - Fork 123
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
ansible hostname task fails with nsenter connection plugin #568
Comments
The default hostnamectl-based strategy being used by the hostname module is systemd: I also tried generic and redhat but they failed with different errors. |
The sles or solaris strategies might appear to work but I'm not sure if editing /etc/hostname or using /usr/bin/hostname to change hostname is supported on EL8. |
I don't think this is a problem with the nsenter connection plugin, but with the hostname module (or maybe even the action of changing the hostname through nsenter in general). There is nothing the nsenter connection plugin can do to improve this situation. |
@felixfontein As that may be, do you know what the cause of the issue is or how the issue could be worked around? |
Seems to also affect the timezone task and timedatectl command. Not sure why but it seems these commands can't talk to systemd via the dbus socket when using nsenter. https://unix.stackexchange.com/questions/639168/why-is-the-uts-namespace-isolation-not-working |
SUMMARY
The hostname Ansible task fails when using the nsenter connection plugin.
ISSUE TYPE
COMPONENT NAME
nsenter connection plugin
https://docs.ansible.com/ansible/latest/collections/community/docker/nsenter_connection.html
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Ansible is running in a privileged podman container that is invoked like this:
sudo podman run --pull=newer --rm -it --pid=host --privileged registry.hub.docker.com/library/fedora:36
It uses nsenter to escape the container and execute the Ansible task on the host.
STEPS TO REPRODUCE
Start a container as described above.
Then
dnf install ansible
, put an example host name in your inventory and doEXPECTED RESULTS
It should be possible to read or set the hostname. I would be very happy to even have read only access to the hostname, which should not require any special privileges?
ACTUAL RESULTS
Extra verbose output shows:
I can reproduce it with the same nsenter command, or even if I do:
Of course hostnamectl works fine on the host itself when not run in a container or nsenter.
I also tried running the podman container with
--network=host
but the result was the same (even though in this case the podman container knows the hostname). In either case, nsenter andhostname -f
works, but hostnamectl does not work.Other Ansible tasks work, only hostname seems to be affected. Maybe something related to permissions in the namespace, but I don't see any other privileges or namespace access that I have not already granted to the podman container.
The text was updated successfully, but these errors were encountered: