33 lines
709 B
YAML
33 lines
709 B
YAML
|
|
---
|
||
|
|
- name: Install required packages
|
||
|
|
apt:
|
||
|
|
name: ethtool
|
||
|
|
state: present
|
||
|
|
update_cache: yes
|
||
|
|
|
||
|
|
- name: Create systemd service for Wake-on-LAN
|
||
|
|
template:
|
||
|
|
src: wol.service.j2
|
||
|
|
dest: /etc/systemd/system/wol.service
|
||
|
|
owner: root
|
||
|
|
group: root
|
||
|
|
mode: '0644'
|
||
|
|
notify:
|
||
|
|
- Reload systemd
|
||
|
|
- Enable and start WOL service
|
||
|
|
|
||
|
|
- name: Enable WOL immediately (without reboot)
|
||
|
|
command: ethtool -s {{ wol_interface }} wol {{ wol_mode }}
|
||
|
|
changed_when: false
|
||
|
|
|
||
|
|
- name: Verify Wake-on-LAN status
|
||
|
|
command: ethtool {{ wol_interface }}
|
||
|
|
register: wol_status
|
||
|
|
changed_when: false
|
||
|
|
when: wol_verify
|
||
|
|
|
||
|
|
- name: Show WOL status
|
||
|
|
debug:
|
||
|
|
msg: "{{ wol_status.stdout_lines }}"
|
||
|
|
when: wol_verify
|