Skip to content

fix(devkit): use RANGE42_INFRASTRUCTURE_CODENAME as Ansible host pattern + fix non-TTY empty stdin#112

Open
t0kubetsu wants to merge 1 commit into
devfrom
fix/devkit-codename-host-pattern-non-tty-stdin
Open

fix(devkit): use RANGE42_INFRASTRUCTURE_CODENAME as Ansible host pattern + fix non-TTY empty stdin#112
t0kubetsu wants to merge 1 commit into
devfrom
fix/devkit-codename-host-pattern-non-tty-stdin

Conversation

@t0kubetsu
Copy link
Copy Markdown

Closes #111

Summary

  • proxmox__inc.jsons.basic_vm_actions.to.jsons.sh: separate ANSIBLE_HOST (for - hosts:) from PROXMOX_NODE (for the proxmox API variable). ANSIBLE_HOST uses RANGE42_INFRASTRUCTURE_CODENAME when set (the Ansible inventory host key, e.g. hv-lab-01) and falls back to PROXMOX_NODE (the PVE cluster node name, e.g. pve).
  • devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh: when cat - returns empty (non-TTY context such as $(...) subshell with no piped input), fall back to $VAULT_NODE instead of silently producing nothing.

Test plan

  • range42-context use <codename> <scenario> on a codename-based deployment
  • range42-context delete-everything completes without "no VM data" error
  • proxmox_vm.list.to.jsons.sh returns VM data when run inside $()
  • Piping an explicit node to the script still works (stdin path not broken)

…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.
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.

fix: devkit commands silently return nothing in codename-based deployments (delete-everything broken)

1 participant