#!/usr/bin/bash # # Pipe the '--list-hosts' output of ansible into this program to wake up all corresponding hosts: # # ansible-playbook [...] -i inventory/inventory.yml -l R317 --list-hosts | ./wol-generator.sh # set -eu tmpf="$(mktemp)" devs='devices.csv' while read -r line ; do sed -nE -e "s%.*(..:..:..:..:..:..);(${line//./\\.});.*%\1 \2%p" "$devs" >> "$tmpf" done < <(cat - | grep -E "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+") wakeonlan -f "$tmpf" rm "$tmpf"