nodes_wait 60 || true # ans CMD: run CMD as greg in his project directory. ans() { timeout 180 runuser -l greg -c "cd ~/ansible && $*" "$OUT" && grep -q . "$OUT" && ! grep -v "uid=0(root)" "$OUT"' task 2 "A second run of bootstrap.yml reports changed=0 on every node" need "/home/greg/ansible/bootstrap.yml exists" '[ -f /home/greg/ansible/bootstrap.yml ]' need "ansible-playbook bootstrap.yml reports changed=0 and no failures" 'ans ansible-playbook bootstrap.yml -e ansible_password=Lab-Pass-1 -e ansible_become_password=Lab-Pass-1 >"$OUT"; grep -Eq "^node[0-9]+ +: ok=" "$OUT" && ! grep -E " : ok=" "$OUT" | grep -Eq "(changed|unreachable|failed)=[1-9]"' task 3 "One inventory host is reached by address, with ansible_host" H=$(ans ansible-inventory --list 2>/dev/null | python3 -c 'import sys, json, re d = json.load(sys.stdin) print(next((h for h, v in d.get("_meta", {}).get("hostvars", {}).items() if re.fullmatch(r"\d+(\.\d+){3}", str(v.get("ansible_host", "")))), ""))' 2>/dev/null) need "an inventory host has ansible_host set to an IPv4 address" '[ -n "$H" ]' need "ansible $H -m ping works" 'ans ansible "$H" -m ping' rm -f "$OUT"