Relax root requirement - allow cluster-tool to run without sudo - #17
Open
danielerez wants to merge 1 commit into
Open
Relax root requirement - allow cluster-tool to run without sudo#17danielerez wants to merge 1 commit into
danielerez wants to merge 1 commit into
Conversation
Remove the requirement to run cluster-tool with sudo. Instead, use sudo internally only for operations that need elevated privileges (HAProxy and DNS configuration). Users run commands normally and are prompted for password only when needed. Changes: 1. Use sudo internally for privileged operations - HAProxy read/write uses 'sudo cat/mv/chmod/systemctl' - DNS configuration uses 'sudo mv/chmod/nmcli' - User prompted for password automatically when needed - User can press Ctrl+C at sudo prompt to skip 2. Use qemu:///system connection for libvirt - Added virsh_cmd() helper that forces qemu:///system - Fixes "Operation not permitted" when creating network bridges - Works when user is in libvirt group 3. Make file ownership changes non-fatal - All 'chown qemu:qemu' operations use check=False - Files remain accessible when user is in libvirt group 4. Improve connect command for non-root usage - Detect if running as root vs regular user - Check for existing packages/services - Graceful degradation with warnings 5. Add configure-access command - Configure HAProxy and DNS separately after boot - Usage: ./cluster-tool configure-access <clone-id> - Useful when user skips sudo during boot 6. Better error messages and output - Show exact commands when sudo fails - Display VM IP when HAProxy not configured - Clear instructions for next steps Prerequisites: - User in libvirt group: sudo usermod -aG libvirt $USER - Required packages installed - User has sudo privileges (prompted when needed) Usage: # Normal - sudo prompts automatically ./cluster-tool boot --flavor my-flavor --name test [sudo] password: ← prompted automatically # Or skip sudo and configure later ./cluster-tool boot --flavor my-flavor --name test [sudo] password: ← press Ctrl+C ./cluster-tool configure-access test Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
danielerez
force-pushed
the
relax-root-requirement
branch
from
June 9, 2026 20:26
04c0662 to
59a8d9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR removes the requirement to run cluster-tool with
sudo. Instead, the tool usessudointernally only for the specific operations that require elevated privileges (HAProxy and DNS
configuration). Users can now run commands normally and will be prompted for their password only
when needed.
Motivation
Previously, cluster-tool had several issues with permissions:
sudo ./cluster-tool ...chownoperations failed without rootqemu:///sessionwhich lacks network bridge permissionsThis made the tool awkward to use and less secure (running everything as root when only small parts
needed it).
Changes
1. Sudo used internally for privileged operations
sudofor/etc/haproxy/haproxy.cfgoperationssudofor/etc/NetworkManager/dnsmasq.d/operations2. Made file ownership changes non-fatal
chown qemu:qemuoperations usecheck=Falselibvirtgroup3. Use qemu:///system connection
virsh_cmd()helper usingqemu:///systemconnectionlibvirtgroup4. Added
configure-accesscommand./cluster-tool configure-access <clone-id>5. Improved connect for non-root usage
6. Robust cleanup
check=FalsePrerequisites
On the server:
libvirtgroup:sudo usermod -aG libvirt $USER(log out/in)On the client (laptop):
./cluster-tool setup clientonce (prompts for sudo password)Usage
Normal workflow (sudo prompts automatically):