Join ownership and handover context
Join asset records to responsible teams without losing unassigned assets.
A finding needs somewhere to go
A capacity warning is more useful when it can be routed to a team. Inventory and ownership may come from different systems, so join them on a stable asset ID rather than a display hostname. Names can change or be reused; the ID is the input contract for this exercise.
The ownership table has one record per asset and a team label that may contain spaces or Unicode. Read it as TSV, keep the complete field, and treat it as data. Never split a team name on ordinary whitespace or use it as a command.
Missing context should remain visible
An asset absent from the ownership table is unassigned, not absent from the fleet. Use a left join: every inventory asset stays in the report. Testing membership in the lookup distinguishes a missing key from a legitimate value. The reference table is validated and contains no duplicate IDs; otherwise a duplicate-key policy would be required.
A header-only ownership table is a valid input and leaves every asset unassigned. Do not use a join shortcut that mistakes the second file for the first when a source is empty. Filename-based selection in awk makes the phases explicit. This report supports a handover conversation; it does not create accounts or change ownership on a real system.
awk -F '\t' 'NR>1 {printf "%s → %s\n",$1,$2}' owners.tsv
Put it into practice.
Join validated inventory.tsv (asset_id<TAB>hostname<TAB>role<TAB>memory_gib) with owners.tsv (asset_id<TAB>team). Both have unique IDs, and team labels are nonempty. Print asset_id<TAB>hostname<TAB>team in inventory order, using unassigned for missing owners. Preserve team spaces and Unicode; ignore ownership rows for assets absent from inventory.
See an explained solution
printf 'asset_id\thostname\tteam\n'
awk -F '\t' 'FILENAME==ARGV[1] {if(FNR>1) team[$1]=$2;next}
FNR>1 {printf "%s\t%s\t%s\n",$1,$2,($1 in team)?team[$1]:"unassigned"}
' owners.tsv inventory.tsv
The left join retains every inventory asset and labels missing responsibility explicitly. Exact ID keys keep unrelated assets separate, and TSV fields preserve human team labels without word splitting.