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

[BUG] sudo password session expiry can cause playbook to fail #1816

Open
jbemmel opened this issue Jan 15, 2025 · 3 comments
Open

[BUG] sudo password session expiry can cause playbook to fail #1816

jbemmel opened this issue Jan 15, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@jbemmel
Copy link
Collaborator

jbemmel commented Jan 15, 2025

I suspect this depends on a sudo session expiring in the middle of a playbook run, but today I had my Linux bonding script (ip netns exec delegated to localhost) fail with an error 'sudo requires a password'

ansible_become_password is not defined for Linux devices, but even if it was it wouldn't be "vagrant" for become delegated to localhost

https://www.omglinux.com/change-sudo-timeout-linux/ has suggestions on how to change the sudo session timeout;
Defaults timestamp_timeout=0 sets it to always require a password (so we could detect these issues)

We could either ask for the password interactively, or ask the user to set an environment variable

@jbemmel jbemmel added the bug Something isn't working label Jan 15, 2025
@ipspace
Copy link
Owner

ipspace commented Jan 16, 2025

When you figure out what's going on we might discuss whether to improve anything. Also, I don't think you can use ansible_become_password on the Ansible host.

Anyway, I expect one of two things from the users: either they know enough Linux to know what they're doing, or they follow the "use netlab on Ubuntu to install everything" recipe. That usually works ;) Trying to accommodate all sorts of Linux distros or "custom" setups is a recipe for a never-ending game of whack-a-mole.

@jbemmel
Copy link
Collaborator Author

jbemmel commented Jan 16, 2025

My Linux setup is not customized, in particular sudo session timeout is set at default (15 minutes I believe)

The use of sudo when starting Containerlab typically triggers an interactive entering of the password. This starts the 15 minute timer. If I happen to start a new lab 1 minute before sudo session expiry, it will get past the Containerlab stage but may hit a wall during Ansible become processing

I suspect it's a simple setting to enable interactive asking for the sudo password in case of become delegated to localhost - but I need to test it out

@ipspace
Copy link
Owner

ipspace commented Jan 16, 2025

If you create a Ubuntu VM from a Vagrant box, there's no timeout on sudo sessions. I got the same setup after installing Ubuntu on my server from an ISO image. Maybe they changed the defaults later?

Anyway, apart from fixing some obvious omission on our part, I don't think it's our job to figure out how Ansible playbooks should deal with sudo setups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants