Interview Prep/Shell Scripting/Scenarios: deployments, user management and fleet operations

Report which servers in a fleet have a different version of `openssl` installed than the approved one.

IntermediateScenarioScenarios: deployments, user management and fleet operations
Answer

Situation read → Collect versions in parallel, compare to the baseline, report drift.

What I'd do →

approved="3.0.13-0ubuntu3.4"
ver() {
  local v
  v=$(ssh -n -o BatchMode=yes -o ConnectTimeout=5 "$1" "dpkg-query -W -f='\${Version}' openssl" 2>/dev/null) || v=unreachable
  echo "$1 ${v:-missing}"
}
export -f ver
xargs -a hosts.txt -P 20 -I{} bash -c 'ver "$1"' _ {} |
  awk -v a="$approved" '$2 != a {print "DRIFT", $0}' | sort
  1. dpkg-query -W -f='${Version}' gives a clean version string (rpm -q --qf '%{VERSION}-%{RELEASE}' on RHEL). The \$ and inner single quotes keep ${Version} from being expanded by either the local or the remote shell.
  2. Unreachable hosts appear as drift so they are not silently skipped.

Why → Version drift is how one unpatched server survives a CVE rollout.

Interview tip → Mention AWS SSM Inventory or osquery for continuous fleet inventory.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Scenarios: deployments, user management and fleet operations