Run explicit simulated remote jobs
Keep host identity, operation and argument separate when collecting fleet results.
A remote job needs a contract
A management wrapper can accept a host, an operation name and structured arguments instead of accepting arbitrary command text. That narrower interface is easier to authorise, test and explain. In this lesson, disk and service are the only supported operations; the argument is a path or service label that remains data.
The supplied remote_job function is a simulation backed by responses.tsv. It does not open SSH, WSMan or any other connection. The table lets the browser model successful results, permission failures and unavailable hosts without granting access to your actual network.
Report failures per host
One unavailable host must not make every other result disappear. Capture each function's status and output, then continue. Preserve the complete host, operation and argument with that result so two hosts running the same operation cannot be confused.
Bash quoting prevents local word splitting and glob expansion, but it does not automatically make arbitrary SSH command strings safe: a remote shell can parse them again. This exercise avoids that second source-code boundary entirely. If you later implement a real transport, define its argument encoding and authentication separately rather than concatenating these fields into a shell command. Record unavailable observations honestly; a connection failure is not proof that a requested service is stopped or a disk is healthy.
source lib/remote.sh
if result=$(remote_job edge1 disk '/srv/data files');then status=0;else status=$?;fi
printf 'status=%s result=%s\n' "$status" "$result"
Put it into practice.
Source lib/remote.sh. jobs.tsv has host<TAB>operation<TAB>argument, all fields nonempty and without tabs/newlines. For each row in order call remote_job(host, operation, argument) exactly as data. Print host<TAB>operation<TAB>argument<TAB>status<TAB>result. Preserve successful and nonzero statuses, continue after failures, and exit 0. The helper supports disk/service, returning 64/unsupported for other operations and 69/unavailable for absent responses. Do not evaluate arguments or make real connections.
See an explained solution
source lib/remote.sh
printf 'host\toperation\targument\tstatus\tresult\n'
{
read -r header
while IFS=$'\t' read -r host operation argument;do
if result=$(remote_job "$host" "$operation" "$argument");then status=0;else status=$?;fi
printf '%s\t%s\t%s\t%s\t%s\n' "$host" "$operation" "$argument" "$status" "$result"
done
} < jobs.tsv
The runner retains a precise operation boundary and reports each host independently. Recorded transport and command failures remain visible, while command-looking arguments stay inert and cannot turn into locally executed source.