To check the status (computers on or off) and if users are logged-in, the following playbook can be run:
- name: Ping
hosts: computers
gather_facts: no
roles:
- role: ufrmath.computer_labs.ping
which uses the role ufrmath.computer_labs.ping.
This role try to ping the computers with:
command ping -c 1 -w 1 {{ ansible_default_ipv4.address }}
and for computers which are on, return the list of logged-in users (not being admin):
who | grep -v admin