From 1ea52d94f92acb3f08756d256747f963997ee259 Mon Sep 17 00:00:00 2001 From: t0kubetsu Date: Thu, 4 Jun 2026 12:03:34 +0200 Subject: [PATCH] fix(devkit): use RANGE42_INFRASTRUCTURE_CODENAME as Ansible host pattern + fix non-TTY empty stdin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh | 5 ++++- proxmox__inc.jsons.basic_vm_actions.to.jsons.sh | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh b/devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh index 2f28751..939037a 100755 --- a/devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh +++ b/devkit_proxmox.STDIN.stdin_or_jsons.to.jsons.sh @@ -52,7 +52,10 @@ NEW_KEY_FIELD_NAME_FROM_STDIN=$(extract_new_key_field_name_from_stdin "$1") JSON_LINE_REQ=$( - { [ -t 0 ] && printf "%s\n" "$VAULT_NODE" || cat -; } | + { [ -t 0 ] && printf "%s +" "$VAULT_NODE" || { _STDIN=$(cat -); [ -n "$_STDIN" ] && printf "%s +" "$_STDIN" || printf "%s +" "$VAULT_NODE"; }; } | jq -R -c --arg key "$NEW_KEY_FIELD_NAME_FROM_STDIN" ' (fromjson? // .) as $v_to_evaluate | if ($v_to_evaluate | type) == "object" then diff --git a/proxmox__inc.jsons.basic_vm_actions.to.jsons.sh b/proxmox__inc.jsons.basic_vm_actions.to.jsons.sh index c6bc7b4..9fdb046 100755 --- a/proxmox__inc.jsons.basic_vm_actions.to.jsons.sh +++ b/proxmox__inc.jsons.basic_vm_actions.to.jsons.sh @@ -265,7 +265,9 @@ if [ ! -t 0 ]; then assign_if_not_empty "dest_proxmox_storage" "$line" ".dest_proxmox_storage" # ARG_ACTION=$(printf "%s\n" "$line" | jq -r ".action") - PROXMOX_NODE=$(printf "%s\n" "$line" | jq -r ".proxmox_node") + PROXMOX_NODE=$(printf "%s +" "$line" | jq -r ".proxmox_node") + ANSIBLE_HOST="${RANGE42_INFRASTRUCTURE_CODENAME:-$PROXMOX_NODE}" #### DEBUG purpose. @@ -282,7 +284,7 @@ if [ ! -t 0 ]; then ( ANSIBLE_CONFIG="$ANSIBLE_CONFIG" \ ansible-playbook -i "$INVENTORY" "${VAULT_ARGS[@]}" /dev/stdin <