feat : Enable Wake-on-LAN persistently

This commit introduces persistent Wake-on-LAN support for Proxmox VE via Ansible. It includes YAML configuration options for the interface, verification, and systemd service management, ensuring reliable functionality after Ansible role execution. The changes also address ignoring outputs and temporary files for a cleaner setup.
This commit is contained in:
2025-12-14 20:46:32 +01:00
parent 04f55958ba
commit 9bef606607
6 changed files with 109 additions and 1 deletions

23
.gitignore vendored
View File

@@ -1,3 +1,24 @@
# ---> Ansible # Ansible specific (optional - ignore temporary output or secrets)
*.retry *.retry
*.vault
*.vault_pass
*.secret
*.log
# VSCode settings
.vscode/
*.code-workspace
# Windows system files
Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.lnk
# Backup files
*~
*.bak
*.swp
*.swo
*.tmp

View File

@@ -1,2 +1,29 @@
# ansible_proxmox_WOL # ansible_proxmox_WOL
This Ansible role enables persistent Wake-on-LAN (WOL) on a Proxmox VE server.
## Variables
| Variable | Default | Description |
|--------|---------|-------------|
| wol_interface | eno1 | Network interface |
| wol_mode | g | WOL mode (magic packet) |
| wol_verify | true | Verify WOL status |
## Requirements
Use the physical NIC, not vmbr0, unless your NIC supports WOL through the bridge
Common interfaces: eno1, enp3s0, eth0
Verify BIOS/UEFI: Enable Wake on LAN
Disable ErP / Deep Sleep
## Example Playbook
```yaml
- hosts: proxmox
become: true
roles:
- role: ansible_proxmox_WOL
vars:
wol_interface: vmbr0

9
defaults/main.yml Normal file
View File

@@ -0,0 +1,9 @@
# Network interface to enable Wake-on-LAN on
wol_interface: "eno1"
# WOL mode:
# g = magic packet (most common)
wol_mode: "g"
# Enable verification task
wol_verify: true

9
handlers/main.yml Normal file
View File

@@ -0,0 +1,9 @@
---
- name: Reload systemd
command: systemctl daemon-reexec
- name: Enable and start WOL service
systemd:
name: wol.service
enabled: yes
state: started

32
tasks/main.yml Normal file
View File

@@ -0,0 +1,32 @@
---
- 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

10
templates/wol.service.j2 Normal file
View File

@@ -0,0 +1,10 @@
[Unit]
Description=Enable Wake-on-LAN
After=network.target
[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s {{ wol_interface }} wol {{ wol_mode }}
[Install]
WantedBy=multi-user.target