Skip to content

fix(install): probe sudo capability instead of guessing from sudoers filename#3129

Merged
vpetersson merged 1 commit into
masterfrom
fix/installer-become-pass-probe
Jul 7, 2026
Merged

fix(install): probe sudo capability instead of guessing from sudoers filename#3129
vpetersson merged 1 commit into
masterfrom
fix/installer-become-pass-probe

Conversation

@vpetersson

@vpetersson vpetersson commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Issues Fixed

Unattended/headless installs hang forever at BECOME password: on stock Raspberry Pi OS: run_ansible_playbook decides whether Ansible needs --ask-become-pass by checking for the installer's own convention file (/etc/sudoers.d/010_<user>-nopasswd), but Raspberry Pi OS grants the first user passwordless sudo via 010_pi-nopasswd — a fixed filename whatever the username — so the check misfires and Ansible prompts for a password that is never needed.

Description

Replace the filename check with a capability probe: sudo -K followed by sudo -n true. The -K matters — without it, a password typed for an earlier apt-get call leaves a cached credential that makes sudo -n succeed, the prompt is skipped, and the playbook then dies mid-run with "Missing sudo password" once the sudo timestamp expires.

Verified:

  • Full installer run from this branch on a Raspberry Pi 5 (Pi OS trixie, cloud-init NOPASSWD grant only, no 010_<user>-nopasswd file): no BECOME password: prompt appeared, playbook completed ok=59 failed=0, all containers healthy after reboot. The unfixed installer on the identical setup hangs at the prompt.
  • x86 device with NOPASSWD sudo: probe passes, --ask-become-pass skipped.
  • Container with a password-only sudo user and a freshly cached credential: without -K the probe wrongly passes; with -K it correctly falls back to --ask-become-pass.

Checklist

  • I have performed a self-review of my own code.
  • New and existing unit tests pass locally and on CI with my changes.
  • I have done an end-to-end test for Raspberry Pi devices.
  • I have tested my changes for x86 devices.
  • I added a documentation for the changes I have made (when necessary).

🤖 Generated with Claude Code

…filename

- run_ansible_playbook only skipped --ask-become-pass when
  /etc/sudoers.d/010_<user>-nopasswd existed, our own convention file
- stock Raspberry Pi OS grants the first user NOPASSWD via
  010_pi-nopasswd (fixed name), so the check misfired and Ansible
  prompted for a password; unattended installs hang forever at
  "BECOME password:"
- probe with sudo -K + sudo -n true: -K drops cached credentials so a
  password typed for an earlier apt call can't fake passwordless sudo
  and kill the playbook mid-run once the timestamp expires

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vpetersson vpetersson requested a review from a team as a code owner July 7, 2026 16:36
@vpetersson vpetersson self-assigned this Jul 7, 2026
@vpetersson vpetersson requested a review from Copilot July 7, 2026 16:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud

sonarqubecloud Bot commented Jul 7, 2026

Copy link
Copy Markdown

@vpetersson vpetersson requested a review from Copilot July 7, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@vpetersson vpetersson requested a review from Copilot July 7, 2026 19:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@vpetersson vpetersson merged commit c12ccfd into master Jul 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants