feat: add --user override and per-server env to fleet exec/ssh (#763, #816)#944
Merged
feat: add --user override and per-server env to fleet exec/ssh (#763, #816)#944
Conversation
…816) Two fleet improvements: 1. --user flag on fleet exec and ssh (#763): Override the SSH user for a single invocation without maintaining duplicate server entries. Threads through collect_exec and applies to each SshClient before execution. homeboy fleet exec fleet-servers --user root -- homeboy update homeboy ssh extra-chill --user root -- systemctl restart nginx 2. Per-server env config (#816): Servers can declare environment variables in their config JSON. Values are injected via 'export K=V && ...' before every command, handling non-interactive SSH's limited PATH. Applies to both execute() and execute_interactive(). { "env": { "PATH": "/home/user/.local/bin:$PATH" } } Both features propagate through all SSH consumers (fleet exec, ssh, deploy, file ops) transparently via SshClient.
Contributor
Homeboy Results —
|
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
--useroverride (#763)Override the SSH user for a single invocation:
homeboy fleet exec fleet-servers --user root -- homeboy update homeboy ssh extra-chill --user root -- systemctl restart nginxNo more maintaining duplicate server entries for the same host. The configured user stays correct for deploys,
--useroverrides for admin ops.Per-server
envconfig (#816)Servers can declare environment variables that are injected before every SSH command:
{ "id": "extra-chill", "host": "178.156.238.82", "user": "opencode", "env": { "PATH": "/home/opencode/.local/bin:$PATH" } }Solves the non-interactive SSH PATH problem —
fleet execnow finds user-local binaries.Implementation
Serverstruct getsenv: HashMap<String, String>(serde-defaulted, skip-if-empty)SshClientgetsenvfield +prepend_env()method that wraps commands withexport K=V && ...execute()andexecute_interactive()— all SSH consumers get env injection for freeCloses #763, #816