Wake on LAN can be performed with the following Ansible playbook:
- name: Wake on LAN
hosts: computers
gather_facts: no
roles:
- role: ufrmath.computer_labs.wol
broadcast: 10.0.2.255
which uses the role ufrmath.computer_labs.wol
Note that a non-expiring Ansible cache is needed (consider adding fact_caching with fact_caching_timeout=0 to Ansible configuration), as the MAC addresses need to be known while the computers are off.
down the computers, it suffices to run the following playbook:
- name: Shutdown computers
hosts: computers
gather_facts: no
tasks:
- name: Shutdown
command: shutdown +1
become: true