fix(devkit): use RANGE42_INFRASTRUCTURE_CODENAME as Ansible host pattern + fix non-TTY empty stdin#112
Open
t0kubetsu wants to merge 1 commit into
Open
Conversation
…ern + fix non-TTY empty stdin
Two bugs broke `range42-context delete-everything` (and any devkit command
run inside command substitution `$(...)`) in codename-based range42 deployments:
Bug 1 — wrong Ansible host pattern (`proxmox_vm.list.to.jsons.sh` silent empty)
proxmox__inc.jsons.basic_vm_actions.to.jsons.sh used `proxmox_node` (= PVE
cluster node name, e.g. "pve") as the Ansible `- hosts:` pattern. In range42,
the inventory host is the codename (e.g. "hv-lab-01"), not the PVE node name.
Ansible warned "Could not match supplied host pattern, ignoring: pve" and
produced no output.
Fix: add ANSIBLE_HOST="${RANGE42_INFRASTRUCTURE_CODENAME:-$PROXMOX_NODE}" and
use ANSIBLE_HOST for `- hosts:` while keeping PROXMOX_NODE for the proxmox_node
API variable (which must stay as the PVE cluster node name).
Bug 2 — non-TTY empty stdin in command substitution
devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh used `[ -t 0 ]` to decide
whether to use VAULT_NODE or read from stdin. Inside `$()`, stdin is not a TTY
even when nothing is piped, so `cat -` read empty and produced no JSON — the
entire pipeline returned nothing silently.
Fix: when `cat -` returns empty (non-TTY, no stdin), fall back to VAULT_NODE
instead of producing no output.
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.
Closes #111
Summary
proxmox__inc.jsons.basic_vm_actions.to.jsons.sh: separateANSIBLE_HOST(for- hosts:) fromPROXMOX_NODE(for the proxmox API variable).ANSIBLE_HOSTusesRANGE42_INFRASTRUCTURE_CODENAMEwhen set (the Ansible inventory host key, e.g.hv-lab-01) and falls back toPROXMOX_NODE(the PVE cluster node name, e.g.pve).devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh: whencat -returns empty (non-TTY context such as$(...)subshell with no piped input), fall back to$VAULT_NODEinstead of silently producing nothing.Test plan
range42-context use <codename> <scenario>on a codename-based deploymentrange42-context delete-everythingcompletes without "no VM data" errorproxmox_vm.list.to.jsons.shreturns VM data when run inside$()