Compare commits

...

76 Commits

Author SHA1 Message Date
9ac1187318 refactor ♻️: Reorder and repeat 'Report WOL configuration' task
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 11s
Gitleaks Scan / gitleaks (push) Successful in 5s
Markdown Lint / markdown-lint (push) Successful in 1m22s
Mark stale issues and pull requests / stale (push) Successful in 2s
This refactoring reorders the 'Report WOL configuration' task to ensure it is repeated as part of the process, improving clarity and completeness.
2026-01-25 11:57:09 +01:00
6d03aacc85 style 💎: Remove extra spaces in 'Multiple Bridges' table row
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 10s
Gitleaks Scan / gitleaks (push) Successful in 4s
Markdown Lint / markdown-lint (push) Successful in 1m15s
ai-reviews / Review PR (pull_request) Successful in 9s
ansible-lint / Ansible Lint (pull_request) Successful in 10s
Gitleaks Scan / gitleaks (pull_request) Successful in 4s
Markdown Lint / markdown-lint (pull_request) Successful in 1m9s
Cleaned up formatting by removing unnecessary spaces within a specific table row to improve readability.
2026-01-25 11:34:41 +01:00
8be72bc931 docs 📝: Fix typo and update bridge layout
Some checks failed
ansible-lint / Ansible Lint (push) Successful in 10s
Gitleaks Scan / gitleaks (push) Successful in 5s
Markdown Lint / markdown-lint (push) Failing after 1m8s
Corrected a minor typo in the README.md file and improved the visual clarity of the bridge layout.
2026-01-25 11:19:52 +01:00
b9358eb043 docs 📝: Refine README formatting and slightly rephrase some sentences for clarity.
Some checks failed
ansible-lint / Ansible Lint (push) Successful in 10s
Gitleaks Scan / gitleaks (push) Successful in 4s
Markdown Lint / markdown-lint (push) Failing after 1m18s
Updated the README file to improve its readability and clarity by refining the formatting and rephrasing certain sentences.
2026-01-25 11:09:02 +01:00
36401dc8f4 chore 📦: Add markdown linting config for line length and code block formatting
Some checks failed
ansible-lint / Ansible Lint (push) Successful in 9s
Gitleaks Scan / gitleaks (push) Successful in 4s
Markdown Lint / markdown-lint (push) Failing after 1m8s
This commit adds a new markdown linting configuration to enforce line length limits and consistent formatting of code blocks across the project.
2026-01-25 10:50:44 +01:00
9a6ac67e20 docs 📝: Reformatted README.md for better readability and added table of contents.
Some checks failed
ansible-lint / Ansible Lint (push) Successful in 10s
Gitleaks Scan / gitleaks (push) Successful in 5s
Markdown Lint / markdown-lint (push) Failing after 1m20s
Improved the structure and accessibility of the README file by reformatting it and adding a table of contents to make it easier for users to navigate.
2026-01-25 10:44:26 +01:00
9d35c16d2c style 💎: Fix minor formatting and punctuation
Some checks failed
ansible-lint / Ansible Lint (push) Successful in 11s
Gitleaks Scan / gitleaks (push) Successful in 9s
Markdown Lint / markdown-lint (push) Failing after 1m13s
Updated README.md to improve readability by fixing minor formatting and punctuation issues.
2026-01-25 10:36:25 +01:00
74474c263d chore 📦: Add new markdown lint configuration, Ansible best practices, README guidelines, AI PR review workflow, and security checks.
Some checks failed
ansible-lint / Ansible Lint (push) Successful in 11s
Gitleaks Scan / gitleaks (push) Successful in 4s
Markdown Lint / markdown-lint (push) Failing after 1m17s
This commit includes the addition of a new markdown lint configuration to disable MD041 rule. It also introduces an Ansible best practices file, README guidelines for comprehensive project files, an AI PR review workflow, and new security checks using Gitleaks and markdown-lint.
2026-01-25 10:32:26 +01:00
a82bd5bac5 refactor ♻️: Refactor task management by removing unused task and adjusting pause duration.
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 10s
This commit refactors the task management system by removing an unused task and adjusting the pause duration to ensure consistent behavior across different environments.
2026-01-25 09:08:09 +01:00
44f9c8ffa9 refactor ♻️: Refactor WOL task to use localhost
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 11s
This commit refactors the existing WOL task by commenting out the original implementation and adding a new one that sends a Wake-on-LAN packet from localhost.
2026-01-25 09:00:53 +01:00
d509a4946e refactor ♻️: Remove unnecessary delegate_to: localhost from WOL tasks
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 11s
Refactored WOL task configuration by removing redundant 'delegate_to: localhost' directive to simplify and improve readability.
2026-01-25 08:59:22 +01:00
f2ead2ad47 feat : Add task to install wakeonlan and send WOL packets
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit introduces a new feature that includes adding a task to install the `wakeonlan` package and sending Wake-on-LAN (WOL) packets. This allows for remote control of devices by waking them up from a powered-off state.
2026-01-25 08:57:07 +01:00
af4c561b3d feat : Add pause before sending Wake-on-LAN packet
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 11s
This feature introduces a delay before sending a Wake-on-LAN (WoL) packet to ensure the network is ready, improving reliability and reducing potential issues during power-up.
2026-01-25 08:45:33 +01:00
d0774ff2b3 refactor ♻️: Refactored WOL packet capture and validation logic
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Improved the efficiency and readability of the WOL packet handling by refactoring the existing code. This includes restructuring the validation logic and optimizing the capture process.
2026-01-25 08:30:39 +01:00
21ec247569 feat : Add support for starting tcpdump with 'become: true' in wakeonlan module
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit introduces the functionality to start tcpdump using elevated privileges by setting 'become: true' in the wakeonlan module. This enhancement ensures that tcpdump can capture network traffic even when run as a non-root user.
2026-01-25 08:23:32 +01:00
a0db41cb81 fix 🐛: Fix issue with multiple interfaces and MAC addresses
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This fix targets the first element in the list to resolve issues related to multiple interfaces and MAC addresses.
2026-01-25 07:18:50 +01:00
e8e8f6d51b Fix corrupted .ansible-lint git object
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
2026-01-25 07:12:42 +01:00
907592b88b refactor ♻️: Refactor interface filter to include 'nic'
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 10s
Updated the interface filter to include the 'nic' option, enhancing the filtering capabilities.
2026-01-24 12:29:17 +01:00
00a6fcc966 refactor ♻️: Add changed_when: true to tasks for better task tracking
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 10s
ansible-lint / Ansible Lint (pull_request) Successful in 10s
This refactoring adds the 'changed_when' attribute to Ansible tasks, enhancing their ability to report changes accurately and improving overall task tracking.
2025-12-26 16:30:29 +01:00
0e16e350de refactor ♻️: Refactor shell commands for better error handling and consistency
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Updated shell commands to use `ansible.builtin.shell` with `executable: /bin/bash`, added `set -o pipefail` for improved error propagation, and refactored variable registration for clarity.
2025-12-26 16:28:30 +01:00
78f20966c3 refactor ♻️: Remove unused 'wol_bridges' variable
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This commit refactors the code by removing an unused variable named 'wol_bridges'. This change simplifies the codebase and eliminates unnecessary memory usage.
2025-12-26 16:13:49 +01:00
c5a1346eea docs 📝: Update README.md with usage examples, scenario descriptions, and known issues
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 11s
This commit updates the README.md file to include a new section on 'Usage Examples' with detailed examples of how to use the role in different scenarios. It also updates the 'Common Proxmox Scenarios' table with more detailed descriptions and adds a new section on 'Known Issues'.
2025-12-26 16:03:19 +01:00
921b5d971f Merge remote-tracking branch 'origin/main' into test
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
2025-12-26 12:21:16 +01:00
90da27fe8e refactor ♻️: Refactor task to dynamically append MAC addresses and update debug message
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This refactoring involves updating the task logic to dynamically append MAC addresses to relevant data structures. Additionally, it includes an update to the debug message format for better clarity and consistency.
2025-12-26 12:19:22 +01:00
8e1d095ead feat : Add loop and condition to process en_interfaces
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit introduces a new loop and conditional logic to handle the processing of `en_interfaces`, enhancing the functionality of the system by allowing more comprehensive interface management.
2025-12-26 12:11:18 +01:00
1647839c8c refactor ♻️: Simplify and update task reporting
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the task reporting process to improve clarity and efficiency, updating the code logic while maintaining external behavior.
2025-12-26 12:08:19 +01:00
b1b73151b6 docs 📝: Updated README for multiple bridges and improved persistence method.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
The README has been updated to include instructions for supporting multiple bridges and enhancing the persistence method.
2025-12-26 11:54:23 +01:00
47d10beea0 Merge branch 'test' of https://repo.piave7.duckdns.org/Jose/ansible_proxmox_WOL into test
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 17s
2025-12-26 11:46:04 +01:00
ce52207812 docs 📝: Updated README.md for clarity and improved readability
Fixed minor grammatical errors and reorganized content in the README.md file.
2025-12-26 11:46:01 +01:00
b94be8a6e4 docs 📝: Updated README.md for clarity and improved readability
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Fixed minor grammatical errors and reorganized content in the README.md file.
2025-12-26 11:00:41 +01:00
06a82a8221 feat : Add new task for starting service
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit introduces a new feature to add a task for initiating a service, enhancing the system's functionality.
2025-12-26 10:50:55 +01:00
f11ad0badc refactor ♻️: Refactor ExecStart to use a list for commands and conditionally execute them.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This refactoring involves restructuring the `ExecStart` method to utilize a list of commands instead of a single string. This change allows for more flexible execution based on certain conditions, enhancing the modularity and maintainability of the code.
2025-12-26 10:45:26 +01:00
942625f894 refactor ♻️: Refactor task to use template for creating systemd service.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This commit refactors the existing task to utilize a template for creating systemd services, enhancing modularity and maintainability.
2025-12-26 10:41:25 +01:00
0afc2a0461 feat : Add new handler to reload systemd and restart WOL.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This commit introduces a new handler that allows reloading the systemd configuration and restarting the Wake-on-LAN (WOL) service, ensuring persistent wake-up functionality.
2025-12-26 10:36:19 +01:00
55e5aa94d2 feat : Add new task to disable Wake-on-LAN and update existing task with mode parameter
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit introduces a new feature to disable Wake-on-LAN functionality and enhances an existing task by adding a mode parameter, allowing for more flexible configuration options.
2025-12-26 10:02:46 +01:00
9c3cf0dbcc refactor ♻️: Rename task from 'Enable Wake-on-LAN (magic packet)' to 'Set Wake-on-LAN'
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the task name to be more concise and descriptive, improving clarity and consistency in terminology.
2025-12-26 09:55:17 +01:00
97b2a519eb refactor ♻️: Remove quotes from wol_mode loop condition
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the loop condition in the code to remove unnecessary quotes around the variable `wol_mode`.
2025-12-26 09:30:56 +01:00
37c54251bf fix 🐛: Update loop condition to include quotes around wol_mode
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Modified the loop condition in the code to ensure proper handling of the 'wol_mode' variable by enclosing it in quotes. This change addresses an issue where the variable was not being interpreted correctly due to missing quotes.
2025-12-26 09:26:44 +01:00
aea02a8e39 refactor ♻️: Refactor Wake-on-LAN config to use dynamic mode selection, remove unused bridge mapping.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This refactoring updates the Wake-on-LAN configuration to dynamically select modes based on system capabilities and removes unnecessary logic related to bridge mappings.
2025-12-26 09:24:04 +01:00
6a5c9f5967 refactor ♻️: Simplify Wake-on-LAN task loop variables and conditions
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the Wake-on-LAN task to use more concise and readable loop variables and conditions, improving code clarity without altering its functionality.
2025-12-26 09:19:47 +01:00
a96493eeab refactor ♻️: Refactor Wake-on-LAN task to use zip for parallel processing of interfaces
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This refactoring improves the efficiency of the Wake-on-LAN task by utilizing the `zip` function to process multiple network interfaces in parallel. This change enhances performance and allows WOL functionality when supported on multiple interfaces.
2025-12-26 09:17:42 +01:00
00bc598285 refactor ♻️: Remove commented-out debug tasks and update Wake-on-LAN condition
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the code by removing unused commented-out debug tasks and updated the condition for enabling Wake-on-LAN feature to improve performance and reduce unnecessary operations.
2025-12-26 09:13:34 +01:00
39430b88f3 refactor ♻️: Simplify task logic by removing redundant debug outputs and combining checks.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the task processing logic to eliminate unnecessary debug statements and consolidate related conditional checks for improved readability and efficiency.
2025-12-26 09:08:02 +01:00
2dc6fd8158 refactor ♻️: Refactor task handling to use en_interfaces and add non-empty list condition
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit refactors the task handling logic to utilize the `en_interfaces` module and includes a conditional check for non-empty lists, enhancing code readability and functionality.
2025-12-26 08:50:11 +01:00
a26cb5d0cf feat : Add WoL status and interface mode support
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Implemented new features to display Wake-on-LAN (WoL) status and supported modes for network interfaces.
2025-12-26 08:47:13 +01:00
a8d178ad6b refactor ♻️: Remove redundant variable from debug message
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Refactored code by removing an unnecessary variable that was being used in a debug message, simplifying the logic and improving readability.
2025-12-26 08:38:02 +01:00
95f52e061b refactor ♻️: Refactor debug task to include wol_enabled values
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Updated the debug task to display the `wol_enabled` status for all items, enhancing visibility and usability.
2025-12-26 08:34:56 +01:00
95c1cd5312 refactor ♻️: Refactor debug output to include wol_enabled results
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Updated the debug output to display the status of `wol_enabled`, enhancing visibility and troubleshooting capabilities.
2025-12-26 08:28:43 +01:00
7c9d61cbe5 feat : Add WOL status check and display feature
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit introduces a new feature that allows users to check and display the Wake-on-LAN (WOL) status for their network interfaces.
2025-12-26 08:25:27 +01:00
c35ff62880 refactor ♻️: Refactor task to extract Supports Wake-on per interface using set_fact and loop.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This refactoring extracts the logic for handling Wake-on settings per network interface into a reusable task. It uses `set_fact` and loops to simplify the configuration process and improve readability.
2025-12-26 08:04:06 +01:00
c3aa02447c refactor ♻️: Refactor regex patterns for better multiline matching and readability
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Updated regex patterns to enhance their ability to handle multiline strings and improved overall code readability.
2025-12-26 07:58:52 +01:00
1b96934164 fix 🐛: Fix typo in variable name
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Corrected a typo in the variable name 'rsults' to 'results' throughout the codebase.
2025-12-26 07:48:37 +01:00
4205a8fc8b fix 🐛: Fix typo in variable names for wol_status results
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Corrected typos in variable names to ensure accurate handling of `wol_status` results.
2025-12-26 07:46:40 +01:00
114ca5af88 feat : Add task extraction and display of Wake-on values
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This commit introduces a new feature that extracts and displays Wake-on values from the `wol_status` endpoint. This enhancement allows for better monitoring and management of device wake-up capabilities.
2025-12-26 07:41:31 +01:00
4ecc0d10f8 feat : Add debug tasks for en_interfaces and wol_status
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit introduces new debug tasks specifically for the `en_interfaces` and `wol_status` modules, enhancing the diagnostic capabilities of these functionalities.
2025-12-26 07:30:06 +01:00
ce888ccf84 fix 🐛: Update regex to match wake-on status with leading whitespace
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Modified the regular expression to accurately capture wake-on status values that may include leading whitespace, ensuring proper parsing and validation.
2025-12-26 07:18:30 +01:00
6e8a9d7631 refactor ♻️: Refactor regex search to use regex_findall and add condition to check if stdout is defined
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
This commit refactors the regex search functionality by replacing the existing method with `regex_findall`. Additionally, it adds a conditional check to ensure that `stdout` is defined before proceeding with the search operation.
2025-12-26 07:10:05 +01:00
5f34c4e959 refactor ♻️: Refactor shell and debug tasks to use ansible.builtin modules
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Updated the shell and debug tasks to utilize `ansible.builtin` modules, enhancing compatibility and improving code clarity.
2025-12-26 07:07:30 +01:00
7a4c9c1583 refactor ♻️: Refactor task display to include WoL status with loop and default output
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Updated the task display logic to include the Wake-on-LAN (WoL) status using a loop, ensuring a more comprehensive and dynamic output.
2025-12-26 07:00:23 +01:00
c3c783cec9 fix 🐛: Update wol_status message to include .stdout
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Modified the `wol_status` function to include the standard output in its message, ensuring more comprehensive status information is provided.
2025-12-26 06:55:29 +01:00
d4b3c31c8e refactor ♻️: Refactor debug message to use wol_status variable
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Updated the debug message to directly utilize the `wol_status` variable, improving readability and reducing redundancy.
2025-12-26 06:49:45 +01:00
dbdf1908e7 refactor ♻️: Simplify interface filtering with regex and streamline task logic.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 8s
Refactored the interface filtering process by simplifying the regex pattern and optimizing the task handling to improve performance and readability.
2025-12-26 06:47:31 +01:00
756e39a498 refactor ♻️: Refactor interface filtering to use dict2items
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This refactoring improves the readability of the interface filtering logic by utilizing the `dict2items` function, making the code more maintainable and easier to understand.
2025-12-26 06:42:46 +01:00
263d061cb1 refactor ♻️: Refactor WOL capability validation to use ethtool
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This refactoring updates the method for validating Wake-On-LAN (WOL) capabilities by utilizing the ethtool utility instead of a previous approach. This change improves accuracy and efficiency in determining WOL support for network interfaces.
2025-12-26 06:30:58 +01:00
01895c78c3 refactor ♻️: Refactor WOL parsing task for better readability and efficiency
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 8s
This refactoring improves the structure and performance of the Wake-On-LAN (WOL) packet parsing task, enhancing both its readability and execution speed.
2025-12-25 21:57:40 +01:00
40f25bbd53 refactor ♻️: Refactor regex and filter logic for Wake-on state extraction
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 9s
Updated regular expression patterns and filtering mechanisms to more accurately extract the Wake-on state from system logs.
2025-12-25 21:50:06 +01:00
670021fcc8 refactor ♻️: Refactor WOL parsing logic
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 9s
Updated WOL parsing to use `select` and `join` for guaranteed matches, improving reliability.
2025-12-25 21:45:03 +01:00
5fd69e4ad7 refactor ♻️: Refactor WOL parsing to use regex_findall and extract the first match
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 9s
This refactoring improves the robustness of WOL (Wake-on-LAN) packet parsing by using `regex_findall` to ensure that only the first matching MAC address is extracted, enhancing reliability in various network environments.
2025-12-25 21:41:16 +01:00
f6d35d0abb refactor ♻️: Refactor Wake-on-LAN support logic and comment out the enable command
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 15s
This commit refactors the Wake-on-LAN (WOL) support logic to improve readability and maintainability. Additionally, it comments out the enable command as part of a larger refactoring effort.
2025-12-25 21:30:57 +01:00
c52fb6c563 refactor ♻️: Refactor task parsing logic
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Updated the task parsing algorithm to handle WOL support and state more robustly, ensuring accurate task management.
2025-12-24 10:59:04 +01:00
672d0457fe refactor ♻️: Refactor WOL status parsing and add Wake-on-LAN enabling logic
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This commit refactors the existing code for parsing Wake-on-LAN (WOL) status and introduces new functionality to enable WOL. The changes improve the clarity and efficiency of the WOL handling mechanism.
2025-12-24 10:55:15 +01:00
1112e01cbf refactor ♻️: Refactor WOL status extraction to handle multiple matches safely.
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 12s
This refactoring improves the handling of multiple matches in the WOL status extraction process, ensuring more robust and reliable results.
2025-12-24 10:48:26 +01:00
3125c4f230 refactor ♻️: Rename 'wol_capabilities_check' to 'wol_check'
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 12s
Refactored the function name and updated all references throughout the codebase to maintain consistency and improve readability.
2025-12-24 10:44:45 +01:00
fb14e6701b feat : Add WOL status display per interface
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 11s
This feature introduces a new section in the build process that includes displaying Wake-On-LAN (WOL) status for each network interface. This allows users to easily monitor and manage WOL capabilities on their devices.
2025-12-24 10:40:31 +01:00
b7f743021f refactor ♻️: Refactor task names and conditions for better clarity and functionality
This refactoring improves the readability and logic of task management by renaming variables and simplifying conditional statements.
2025-12-24 10:32:25 +01:00
7f5ff67e6e Merge pull request 'style 💎: Fix indentation in tasks/main.yml for notify section' (#1) from test into main
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 10s
Reviewed-on: #1
2025-12-24 08:02:17 +01:00
17 changed files with 810 additions and 382 deletions

View File

@@ -0,0 +1,3 @@
{
"MD041": false
}

127
.continue/rules/ansible.md Normal file
View File

@@ -0,0 +1,127 @@
---
name: Ansible Best Practices
description: Ansible best practices and conventions
alwaysApply: false
globs:
- "**/*.yml"
- "**/*.yaml"
---
You are an expert Ansible automation engineer.
When working with Ansible content, always follow these rules:
## General
- Prefer **idempotent** solutions; tasks must be safe to run multiple times.
- Use **Ansible built-in modules** instead of shell or command whenever possible.
- Do not assume root access; use `become: true` only when required.
- Avoid hard-coded values; prefer variables, defaults, and group/host vars.
- Use clear, descriptive task names.
- Ensure all YAML is valid, properly indented, and ansible-lint compliant.
- Favor clarity and maintainability over cleverness.
- Add README files to complex directories.
- Document complex algorithms and business rules.
- Maintain up-to-date dependencies list.
## Security Hardening
- **Never embed secrets** directly in playbooks, roles, or templates.
- Use **Ansible Vault**, external secret managers, or injected variables for secrets.
- Mark sensitive tasks with:
```yaml
no_log: true
```
- Avoid leaking secrets via debug, register, or error messages.
- Use least privilege:
- Avoid running entire plays as root.
- Scope become to individual tasks where possible.
- Set secure file permissions explicitly:
```yaml
mode: "0640"
owner: root
group: root
```
- Validate downloaded files using checksums.
- Avoid ignore_errors for security-sensitive operations.
- Do not disable SSL/TLS validation unless explicitly required and documented.
- Prefer validate_certs: true for network modules.
- Assume hosts may be compromised—do not trust remote state blindly.
## Playbooks
- Use `hosts`, `gather_facts`, and `become` explicitly.
- Keep playbooks minimal; delegate logic to roles.
- Apply tags consistently for safe partial execution.
- Use serial for rolling updates to reduce blast radius.
- Avoid large monolithic plays.
## Roles
- Follow the standard role structure:
(`tasks/`, `handlers/`, `defaults/`, `vars/`, `templates/`, `files/`).
- Put overridable values in `defaults/main.yml`.
- Put non-overridable or internal values in `vars/main.yml`.
- Namespace all role variables (role_name_variable).
- Use meta/main.yml to define role dependencies.
- Use handlers only when a change requires a follow-up action.
## Tasks
- Always name tasks clearly and descriptively.
- Use `state: present/absent/latest` explicitly.
- Register variables only when they are actually used.
- Use `changed_when` and `failed_when` to ensure correct task status.
- Avoid `ignore_errors` unless absolutely necessary.
- Avoid shell unless absolutely unavoidable; document why if used.
- Prefer creates and removes when using command-like tasks.
- Avoid unnecessary loops; simplify logic where possible.
## Variables & Templates
- Use snake_case for variable names.
- Quote variables in YAML to prevent parsing issues.
- Namespace role variables (e.g., `nginx_port`, not `port`).
- Avoid complex logic in templates—use when instead.
- Use Jinja2 filters safely and defensively (default, bool, int).
- Do not reference undefined variables without defaults.
## Conditionals & Loops
- Use when for conditionals.
- Prefer `loop` over deprecated `with_*`.
- Use `ansible_facts` instead of shell commands for system data.
- Avoid deeply nested conditionals.
## Error Handling & Validation
- Fail fast on critical errors.
- Use assert to validate assumptions.
- Use check_mode compatibility whenever possible.
- Ensure tasks behave correctly in --diff and --check.
## Linting & Compatibility
- Code must comply with ansible-lint.
- Write code compatible with recent Ansible versions.
- Avoid deprecated modules and syntax.
- Do not rely on undefined behavior or undocumented features.
## Performance & Reliability (Tips & Tricks)
- Use gather_facts: false if facts are not needed.
- Use run_once and delegate_to when appropriate.
- Cache facts when operating at scale.
- Avoid repeated expensive operations.
- Prefer block for grouping related tasks and error handling.
## Output Expectations
- Generated YAML must be valid and properly indented.
- Provide minimal but sufficient comments when clarity is needed.
- Do not include explanations unless explicitly requested.
- Assume production usage and security-sensitive environments.

View File

@@ -0,0 +1,159 @@
---
name: Project README Standards
globs: "**/README.md"
alwaysApply: false
description: Guidelines for creating comprehensive project README files
tags:
- readme
- documentation
- markdown
- project-setup
- best-practices
---
You are an expert in:
- technical documentation
- open source best practices
- developer experience.
## README Structure
A well-structured README should include these sections in order:
1. Project Title and Description
2. Badges (build status, version, license)
3. Key Features
4. Screenshots/Demo (if applicable)
5. Quick Start
6. Installation
7. Usage Examples
8. API Reference (or link to docs)
9. Configuration
10. Contributing
11. License
## Essential Sections
### Project Header
```markdown
# Project Name
> One-line description of what this project does
[![Build Status](https://img.shields.io/github/actions/workflow/status/user/repo/ci.yml)](https://github.com/user/repo/actions)
[![npm version](https://img.shields.io/npm/v/package-name)](https://www.npmjs.com/package/package-name)
[![License](https://img.shields.io/github/license/user/repo)](LICENSE)
Brief paragraph explaining the project's purpose, main features,
and why someone would want to use it.
```
### Quick Start
```markdown
## Quick Start
Get up and running in less than 5 minutes:
\`\`\`bash
npm install package-name
npm run dev
\`\`\`
Visit http://localhost:3000 to see the application.
```
### Installation
```markdown
## Installation
### Prerequisites
- Node.js 18+
- PostgreSQL 14+
- Redis 6.2+
### Install from npm
\`\`\`bash
npm install package-name
\`\`\`
### Install from source
\`\`\`bash
git clone https://github.com/user/repo.git
cd repo
npm install
npm run build
\`\`\`
```
### Usage Examples
```markdown
## Usage
### Basic Example
\`\`\`javascript
import { Widget } from 'package-name';
const widget = new Widget({
apiKey: 'your-api-key',
theme: 'dark'
});
widget.render('#app');
\`\`\`
### Advanced Example
\`\`\`javascript
// Custom configuration with error handling
const widget = new Widget({
apiKey: process.env.API_KEY,
theme: 'dark',
onError: (error) => {
console.error('Widget error:', error);
}
});
// Add custom event handlers
widget.on('ready', () => {
console.log('Widget is ready');
});
widget.render('#app');
\`\`\`
```
## Best Practices
- Keep the README focused and concise
- Use clear, simple language
- Include code examples that actually work
- Add visuals when they help understanding
- Link to more detailed documentation
- Keep examples up-to-date with the code
- Test your installation instructions regularly
## Common Mistakes to Avoid
- Don't assume reader knowledge
- Don't skip the Quick Start section
- Don't use jargon without explanation
- Don't forget to update version numbers
- Don't include sensitive information
## Formatting Tips
- Use consistent heading levels
- Include a table of contents for long READMEs
- Use code blocks with language highlighting
- Add alt text to images
- Use tables for comparing options
- Include emoji sparingly and purposefully

View File

@@ -0,0 +1,37 @@
---
# https://github.com/kekxv/AiReviewPR
name: ai-reviews
on:
pull_request:
types: [opened, synchronize]
jobs:
review:
name: Review PR
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
# Number of commits to fetch. 0 indicates all history for all
# branches and tags.
# Default: 1
fetch-depth: 0
# The base URL for the GitHub instance that you are trying to clone
# from, will use environment defaults to fetch from the same instance
# that the workflow is running from unless specified.
# Example URLs are https://github.com or
# https://my-ghes-server.example.com
github-server-url: ${{ vars.GIT_SERVER_URL }}
- name: Review code
uses: kekxv/AiReviewPR@v0.1.0
with:
model: ${{ vars.OLLAMA_MODEL }}
host: http://192.168.2.233:11435
# host: ${{ vars.OLLAMA_HOST }}
# ai_token: ${{ secrets.AI_TOKEN }}
REVIEW_PULL_REQUEST: false
LANGUAGE: English

View File

@@ -1,15 +1,17 @@
# .github/workflows/ansible-lint.yml
---
# .gitea/workflows/ansible-lint.yml
name: ansible-lint
on: [pull_request, issues, push]
jobs:
build:
name: Ansible Lint # Naming the build is important to use it as a status check
name: Ansible Lint
# Naming the build is important to use it as a status check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
github-server-url: ${{ vars.GIT_SERVER_URL }}
@@ -21,7 +23,11 @@ jobs:
- name: Install ansible-lint
run: |
python -m pip install --upgrade pip
pip install ansible ansible-lint
pip install ansible ansible-lint yamllint
- name: Run yamllint
run: |
yamllint .
- name: Run ansible-lint
run: |

View File

@@ -0,0 +1,35 @@
---
name: Gitleaks Scan
on:
push:
pull_request:
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- name: Install Gitleaks
run: |
curl -sSL https://github.com/gitleaks/gitleaks/releases/download/v8.30.0/gitleaks_8.30.0_linux_x64.tar.gz \
| tar -xz
sudo mv gitleaks /usr/local/bin/
- name: Checkout code
uses: actions/checkout@v6
with:
github-server-url: ${{ vars.GIT_SERVER_URL }}
- name: Run Gitleaks
run: |
gitleaks dir . \
--redact=10 \
--verbose \
--exit-code 1
# gitleaks detect \
# --source . \
# --no-git \
# --redact=20 \
# --verbose \
# --exit-code 1

View File

@@ -0,0 +1,71 @@
---
# .gitea/workflows/markdown-lint.yml
name: Markdown Lint
on: [pull_request, issues, push]
jobs:
build:
name: markdown-lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
github-server-url: ${{ vars.GIT_SERVER_URL }}
- name: Install Node.js & markdownlint
run: |
apt-get update && apt-get install -y npm
npm install -g markdownlint-cli2
- name: Run lint
run: markdownlint-cli2 "**/*.md" "#node_modules"
# on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
# jobs:
# markdown-lint:
# runs-on: docker
# container:
# image: node:20-alpine
# steps:
# - name: Install dependencies
# run: |
# apk add --no-cache git
# npm install -g markdownlint-cli2
# - name: Run Markdown lint
# run: |
# markdownlint-cli2 "**/*.md" "#node_modules"
#########################################à
# ---
# https://github.com/marketplace/actions/markdownlint-cli2-action
# name: Markdown Lint
# on: [pull_request, push]
# jobs:
# build:
# name: markdown-lint
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# github-server-url: ${{ vars.GIT_SERVER_URL }}
# - name: Markdown lint
# uses: DavidAnson/markdownlint-cli2-action@v22
# with:
# globs: '**/*.md'
# fix: true
# continue-on-error: true

View File

@@ -0,0 +1,72 @@
---
# This workflow warns and then closes issues and PRs that have
# had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Mark stale issues and pull requests
on:
schedule:
- cron: '21 3 * * *'
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write # for actions/stale to close stale issues
pull-requests: write # for actions/stale to close stale PRs
steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# # Number of commits to fetch. 0 indicates all history for all branches
# # and tags.
# # Default: 1
# fetch-depth: 0
# # The base URL for the GitHub instance that you are trying to clone from,
# # will use environment defaults to fetch from the same instance that the
# # workflow is running from unless specified.
# # Example URLs are https://github.com or
# # https://my-ghes-server.example.com
# github-server-url: ${{ vars.GIT_SERVER_URL }}
# The 90 day stale policy
# Used for:
# - Issues & PRs
# - No PRs marked as no-stale or pinned
# - No issues marked as no-stale, help-wanted or pinned
- name: 90 days stale issues & PRs policy
uses: actions/stale@v9.1.0
with:
# repo-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
days-before-stale: 90
days-before-close: 7
operations-per-run: 150
remove-stale-when-updated: true
stale-issue-label: "stale"
exempt-issue-labels: "no-stale,help-wanted,pinned,enhancement"
stale-issue-message: >
There hasn't been any activity on this issue recently. To keep our
backlog manageable we have to clean old issues, as many of them have
already been resolved with the latest updates.
Please make sure to update to the latest version and check if that
solves the issue. Let us know if that works for you by adding a
comment 👍
This issue has now been marked as stale and will be closed if no
further activity occurs. Thank you for your contributions.
stale-pr-label: "stale"
exempt-pr-labels: "no-stale,pinned"
stale-pr-message: >
There hasn't been any activity on this pull request recently. This
pull request has been automatically marked as stale because of that
and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

7
.markdownlint.json Normal file
View File

@@ -0,0 +1,7 @@
{
"MD013": {
"line_length": 100,
"code_block_line_length": 120,
"tables": false
}
}

2
.markdownlintignore Normal file
View File

@@ -0,0 +1,2 @@
# ignore files completely
.continue/rules/**/*.md

23
.yamllint Normal file
View File

@@ -0,0 +1,23 @@
---
# This is my first, very own configuration file for yamllint!
# It extends the default conf by adjusting some options.
extends: default
rules:
comments-indentation: disable # don't bother me with this rule
truthy:
allowed-values: ['true', 'false', 'yes', 'no', 'on']
comments:
min-spaces-from-content: 1
braces:
max-spaces-inside: 1
octal-values:
forbid-implicit-octal: true
forbid-explicit-octal: true
line-length:
max: 120
allow-non-breakable-words: true

281
README.md
View File

@@ -1,51 +1,110 @@
# ansible_proxmox_WOL
A robust, idempotent Ansible role for enabling persistent Wake-on-LAN (WOL) on Proxmox VE servers. This role automatically detects physical network interfaces with WOL capability using Ansible facts and persistently enables WOL via udev rules.
An Ansible role that configures **persistent WakeonLAN (WOL)** on Proxmox VE hosts.
It discovers all physical Ethernet interfaces, validates WOL support, and then enables or disables
WOL on the interfaces that back the bridges you specify. Unlike many WOL setups that rely on
*udev* rules, this role uses a lightweight **systemd template unit** (`wol@.service`) so the setting
is applied automatically each time an interface comes up, and it survives reboots without any extra
steps.
---
## Table of Contents
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Role Variables](#role-variables)
- [How It Works](#how-it-works)
- [Usage](#usage)
- [Common Proxmox Scenarios](#common-proxmox-scenarios)
- [Troubleshooting](#troubleshooting)
- [License](#license)
- [Author](#author)
---
## Features
**Fully Idempotent**: Checks current WOL status and only applies changes when needed
**Multiple Bridge Support**: Configure WOL on multiple bridges simultaneously
**Bond0 Detection**: Automatically detects and configures bonded interfaces
**Ansible Facts-Based**: Uses Ansible facts to detect and validate WOL-capable interfaces
**Safe & Persistent**: Uses udev rules for persistence across reboots
**Comprehensive Validation**: Verifies WOL capability before configuration
**Detailed Reporting**: Shows configuration status and MAC addresses for WOL senders
| Feature | Description |
|---------|-------------|
| ✅ Fully idempotent | Only touches an interface if the desired WOL mode differs from what `ethtool` currently reports. |
| ✅ Multiple bridge support | Pass a single string or a list of bridge names to `wol_bridges`. |
| ✅ Bond0 detection | If a bridge is built on a bond (e.g., `bond0`), all slaves receive the same WOL configuration. |
| ✅ Factsdriven | Uses Ansible facts (`ansible_interfaces`) to filter out virtual and nonEthernet devices. |
| ✅ Persistent via systemd | WOL is enforced by a `wol@.service` template that is started for each enabled interface. |
| ✅ Comprehensive validation | Each interface is queried with `ethtool` to confirm real WOL support before making any changes. |
| ✅ Detailed reporting | The role prints a summary of every interface it touched, including the MAC addresses of WOLcapable senders when `wol_report_mac` is `true`. |
---
## Prerequisites
| Requirement | How the role satisfies it |
|-------------|---------------------------|
| **Proxmox VE host** | Target host runs Debianbased Proxmox (the role uses Debian/Proxmox defaults). |
| **Ansible ≥2.9** | The role only uses builtin modules (`setup`, `package`, `command`, `template`, `systemd`). |
| **ethtool** | The role installs the `ethtool` package if it is not already present. |
| **Root / sudo access** | All tasks modify network configuration; `become: true` is required. |
| **BIOS/WMI WOL** | WOL must be enabled in the host BIOS and the NIC driver must expose the `WakeOnLAN` flag. |
---
## Role Variables
| Variable | Default | Type | Description |
|----------|---------|------|-------------|
| `wol_bridges` | `vmbr0` | string/list | Bridge interface(s) to enable WOL on. Can be a single bridge as string or multiple bridges as a list. |
| `wol_mode` | `g` | string | WOL mode: `g` (magic packet - recommended), `d` (disable), `p` (physical activity), `u` (unicast), `m` (multicast), `b` (broadcast) |
| `wol_verify` | `true` | boolean | Verify WOL status after configuration and display results |
| `wol_report_mac` | `true` | boolean | Include MAC addresses in configuration report |
```yaml
# defaults/main.yml
wol_bridges: vmbr0 # string or list bridges that should have WOL enabled
wol_mode: "g" # "g"=magic packet (recommended), "d"=disable, "p"/"u"/"m"/"b" for other modes
wol_verify: true # Verify the interface state after changes
wol_report_mac: true # Include MAC addresses of WOL-capable senders in the report
```
| Variable | Default | Type | Description |
|----------------|---------|-----------|-------------|
| `wol_bridges` | `vmbr0` | string/list | Bridge(s) to configure. If you pass a string, the role treats it as a singleitem list. |
| `wol_mode` | `"g"` | string | Desired WOL mode. See the variable table above for valid options. |
| `wol_verify` | `true` | bool | Whether to run `ethtool` again after the changes and include the result in the final report. |
| `wol_report_mac` | `true` | bool | Whether to list the MAC address of each NIC that will send WOL packets. |
---
## How It Works
1. **Package Installation**: Ensures `ethtool` is installed for WOL management
2. **Interface Discovery**: Uses Ansible facts to identify all physical Ethernet interfaces
3. **WOL Validation**: Tests each interface for Wake-on-LAN capability using ethtool
4. **Bridge Mapping**: Maps configured bridges to their backing WOL-capable physical NICs
5. **Bond0 Detection**: Detects if interfaces are bonded and extracts slave information
6. **Idempotency Check**: Reads current WOL status to avoid redundant changes
7. **Enable WOL**: Applies WOL settings only to interfaces that need it
8. **Persist Settings**: Creates/updates udev rules for persistence across reboots
9. **Reload Udev**: Reloads udev rules and triggers network interface refresh
10. **Verification & Reporting**: Displays WOL configuration status and MAC addresses
1. **Package Install** Ensures the `ethtool` binary is present.
2. **Interface Discovery** Uses `ansible_facts.ansible_interfaces` to collect *all* interfaces,
then filters out virtual ones (`veth*`, `tap*`, `docker*`, etc.).
3. **WOL Validation** For each remaining physical NIC, `ethtool <iface> | grep 'Wake-on'`
is used to confirm that the NIC supports WOL.
4. **Bridge Mapping** Resolves each bridge name in `wol_bridges` to the physical interface(s).
If a bridge is built on a bond (e.g., `bond0`), every slave is treated as a candidate.
5. **Idempotency Check** The current WOL state (`wol_enabled`) is compared to `wol_mode`.
6. **Apply WOL**
- If `wol_mode` ≠ `'d'` and the current mode differs, `ethtool -s <iface> wol <mode>` is run.
- If `wol_mode` is `'d'`, the role ensures WOL is disabled.
7. **Deploy systemd template** Copies `templates/wol@.service.j2` to `/etc/systemd/system/wol@.service`.
The template contains `ExecStart=/usr/sbin/ethtool -s %I wol {{ wol_mode }}`.
8. **Enable service per interface** For every interface, the role starts the unit
`wol@<iface>.service` and enables it to run on boot.
9. **Report** A final summary is printed, optionally listing MAC addresses if `wol_report_mac`
is `true`.
## Usage Examples
---
## Usage
### Basic Playbook
### Basic Single Bridge (Auto-Detection)
```yaml
- hosts: proxmox
become: true
roles:
- ansible_proxmox_WOL
```
Automatically configures WOL for the default `vmbr0` bridge.
> **Result** WOL is automatically enabled on the physical NIC that backs the default `vmbr0` bridge.
### Multiple Bridges
```yaml
- hosts: proxmox
become: true
@@ -57,9 +116,25 @@ Automatically configures WOL for the default `vmbr0` bridge.
- vmbr1
- vmbr2
```
Configures WOL for multiple bridge interfaces simultaneously.
### Custom Bridge with Verification Disabled
> **Result** All three bridges are processed; the physical NICs that belong to each bridge
> receive the configured WOL mode.
### Disable WOL
```yaml
- hosts: proxmox
become: true
roles:
- role: ansible_proxmox_WOL
vars:
wol_mode: d
```
> **Result** WOL is disabled on every physical NIC that the role discovered, regardless of bridge.
### Turn Off Verification
```yaml
- hosts: proxmox
become: true
@@ -70,150 +145,38 @@ Configures WOL for multiple bridge interfaces simultaneously.
wol_verify: false
```
### Disable WOL
```yaml
- hosts: proxmox
become: true
roles:
- role: ansible_proxmox_WOL
vars:
wol_mode: d
```
> **Result** WOL is set on `vmbr1`s backing NIC(s) but the role does not perform a postchange check.
## Bond0 Support
The role automatically detects if configured bridges are backed by bonded interfaces (bond0). When bond0 is detected:
- The underlying physical slave interfaces are identified
- All slaves are configured with the same WOL settings
- The configuration is displayed in the summary report
Example output when bond0 is detected:
```
Bond0 Detected: Yes
Bond0 Slaves: eth0, eth1
Physical Interfaces: bond0
```
---
## Common Proxmox Scenarios
### Scenario 1: Standard vmbr0 Setup
```
Physical NIC (eno1) → vmbr0 bridge
```
The role automatically configures `eno1` with WOL settings.
| Scenario | Bridge / NIC Layout | What the role does |
|----------|-------------------|------------------|
| **Standard vmbr0** | `eno1``vmbr0` | Enables WOL on `eno1`. |
| **Bonded NICs** | `eno1`, `eno2``bond0``vmbr0` | Detects `bond0` and sets WOL on *both* slaves. |
| **Multiple Bridges** | - `eno1``vmbr0` - `eno2``vmbr1` - `eno3`, `eno4``bond0``vmbr2` | One role run configures all three bridges automatically. |
### Scenario 2: Bonded Interface
```
Physical NICs (eno1, eno2) → bond0 → vmbr0 bridge
```
The role detects bond0 and applies WOL to bonded slaves.
### Scenario 3: Multiple Bridges
```
eno1 → vmbr0
eno2 → vmbr1
bond0 (eno3, eno4) → vmbr2
```
Configure all bridges with one role application:
```yaml
wol_bridges:
- vmbr0
- vmbr1
- vmbr2
```
## Prerequisites
- **Proxmox VE** host with bridge interfaces configured
- **Ansible** 2.9+
- **ethtool** package (installed automatically by role)
- **Root/sudo access** on target host (required for udev and ethtool)
- **BIOS Configuration**:
- Wake-on-LAN enabled in BIOS
- ErP (Energy-Related Products) disabled in BIOS
## Idempotency
This role is fully idempotent. Running it multiple times has the same effect as running it once:
- ✅ Only enables WOL on interfaces that don't already have it enabled
- ✅ Skips udev rule reload if rules haven't changed
- ✅ Uses `changed_when` conditions to accurately report actual changes
- ✅ Safe to include in recurring Ansible playbooks and AWX workflows
## Safety
- **Non-Destructive**: Never disables interfaces or changes bridge configuration
- **Validation**: Verifies NIC WOL capability before making changes
- **Error Handling**: Fails gracefully with clear error messages if:
- Bridges cannot be detected
- Physical NICs cannot be found
- NICs don't support Wake-on-LAN
- **Check Mode Support**: Fully compatible with `--check` mode for safe preview
## Implementation Details
### Persistence Method
WOL settings are persisted using udev rules at `/etc/udev/rules.d/90-wol.rules`. This is the most reliable method for Debian/Proxmox systems and survives:
- System reboots
- Network service restarts
- Interface state changes
Example generated udev rule:
```
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eno1", RUN+="/sbin/ethtool -s eno1 wol g"
```
### Detection Logic
1. **Interface Discovery**: Uses Ansible facts to enumerate all network interfaces
2. **Physical Interface Filtering**: Filters for Ethernet interfaces, excluding virtual interfaces (veth, tap, fw*, docker, br*)
3. **WOL Capability Testing**: Tests each physical interface with ethtool to verify WOL support
4. **Bridge Mapping**: Maps configured bridges to their backing WOL-capable physical NICs
5. **Bond0 Detection**: Extracts slave interfaces from `/proc/net/bonding/bond0` when present
---
## Troubleshooting
### "No network interfaces found that support Wake-on-LAN"
- Check BIOS settings to ensure WOL is enabled
- Verify NIC drivers support WOL: `ethtool <interface>`
- Some NICs may require specific BIOS settings or driver parameters
- Check if interfaces are properly detected: `ansible -m setup <host> | grep ansible_interfaces`
| Problem | Likely Cause | Fix |
|---------|--------------|-----|
| **No interfaces found that support WOL** | BIOS WOL disabled, NIC driver doesnt expose the feature, or interface isnt a physical NIC. | Enable WOL in BIOS, run `ansible -m setup <host> \| grep ansible_interfaces`. |
| **Unable to detect bridge backing NIC(s)** | Bridge doesnt exist or the NIC isnt a member of it. | Verify with `bridge link show` / `brctl show`. |
| **WOL not persisting after reboot** | `wol@.service` isnt enabled, or `ethtool` isnt installed. | Ensure the role ran successfully, check `/etc/systemd/system/wol@.service` and `systemctl status wol@<iface>.service`. |
| **Bond0 not detected** | Bond configuration file missing or wrong. | Check `/proc/net/bonding/bond0`. |
| **WOL mode unsupported** | NIC driver only supports a subset of modes. | Try a different `wol_mode` value (e.g., `p`, `u`, `m`, `b`). |
### "Unable to detect physical NIC backing bridge(s)"
- Verify bridges exist: `bridge link show`
- Check bridge configuration: `brctl show`
- Ensure physical NIC is member of bridge
- Confirm the backing interface supports WOL (listed in "Available WOL-capable interfaces")
### "Does not support Wake-on-LAN"
- Check NIC capabilities: `ethtool <interface>`
- Verify BIOS has WOL enabled for the specific NIC
- Some NICs have disabled WOL by default (check driver documentation)
- Try different WOL modes: `p`, `u`, `m`, or `b`
### WOL not persisting after reboot
- Check udev rules: `cat /etc/udev/rules.d/90-wol.rules`
- Verify ethtool installed: `which ethtool`
- Check system logs: `journalctl -u systemd-udevd -b`
- Ensure udev service is running: `systemctl status systemd-udevd`
### Bond0 not detected
- Check bond status: `cat /proc/net/bonding/bond0`
- Verify bond is backing the configured bridge
- Check bond slave interfaces support WOL individually
## Notes for Proxmox Admins
- **Default Bridge**: Proxmox typically uses `vmbr0` as the default management bridge
- **No DHCP Changes**: This role only configures WOL; it doesn't modify IP configuration
- **Performance Impact**: WOL has negligible performance impact
- **Network Redundancy**: If using bonds or multiple bridges, all configured interfaces will be enabled for WOL
---
## License
MIT
---
## Author
Ansible Proxmox WOL Contributors

View File

@@ -1,11 +1,4 @@
---
# ============================================================
# Bridge interfaces to enable Wake-on-LAN on
# Can be a string (single bridge) or list (multiple bridges)
# Supports detection of physical NICs backing bridges
# ============================================================
wol_bridges: vmbr0
# ============================================================
# WOL mode options:
# g = magic packet (most common, highly recommended)
@@ -25,3 +18,5 @@ wol_verify: true
# Report MAC addresses for WOL packet senders
wol_report_mac: true
wol_port: 9

View File

@@ -1,15 +1,4 @@
---
- name: Reload systemd and restart WOL
- name: Reload systemd
ansible.builtin.systemd:
name: wol
daemon_reload: true
enabled: true
state: restarted
- name: Reload_udev_rules
ansible.builtin.command: udevadm control --reload
changed_when: false
- name: Trigger_udev_net
ansible.builtin.command: udevadm trigger --subsystem-match=net
changed_when: false

View File

@@ -4,7 +4,9 @@
# ============================================================
- name: Install required packages
ansible.builtin.apt:
name: ethtool
name:
- ethtool
- wakeonlan
state: present
update_cache: true
@@ -17,206 +19,141 @@
- network
when: ansible_facts.interfaces is not defined
- name: Display WOL status per interface
- name: Display interfaces
ansible.builtin.debug:
msg: >
{{ ansible_facts.interfaces }}
- name: Get interfaces starting with "en"
ansible.builtin.set_fact:
en_interfaces: "{{ ansible_facts.interfaces | select('match', '^eth|^ens|^enp') | unique | list }}"
# - name: Get interfaces starting with "en" or "eth"
# ansible.builtin.set_fact:
# en_interfaces: "{{ ansible_facts.interfaces | select('match', '^eth|^ens|^enp') | unique | list }}"
- name: Display WOL interface
- name: Get interfaces starting with "en, "eth" or "nic"
ansible.builtin.set_fact:
en_interfaces: >-
{{
ansible_facts.interfaces
| select('match', '^(eth|en|nic)')
| list
}}
- name: Display debug selected interfaces
ansible.builtin.debug:
msg: >
{{ en_interfaces }}
- name: Validate WOL capability using ethtool for detected interfaces
ansible.builtin.command: "ethtool {{ item }}"
register: wol_capabilities_check
- name: Check supported Wake-on-LAN modes
ansible.builtin.shell: |
set -o pipefail
ethtool {{ item }} | grep 'Supports Wake-on' | tail -1 | awk '{print $3}'
args:
executable: /bin/bash
changed_when: false
loop: "{{ en_interfaces }}"
register: wol_supported
when: en_interfaces | length > 0
- name: WOL | Check if enabled
ansible.builtin.shell: |
set -o pipefail
ethtool {{ item }} | grep 'Wake-on' | tail -1 | awk '{print substr($0,length,1)}'
args:
executable: /bin/bash
changed_when: false
failed_when: false
loop: "{{ en_interfaces }}"
register: wol_enabled
when: en_interfaces | length > 0
- name: Display ethtool output for detected interfaces
- name: "Set Wake-on-LAN to {{ wol_mode }}"
ansible.builtin.command: "ethtool -s {{ item.0 }} wol {{ wol_mode }}"
loop: "{{ en_interfaces | zip(wol_enabled.results, wol_supported.results) | list }}"
loop_control:
label: "{{ item.0 }}"
when:
- wol_mode not in item.1.stdout
- wol_mode in item.2.stdout
changed_when: true
- name: "Disable Wake-on-LAN"
ansible.builtin.command: "ethtool -s {{ item.0 }} wol {{ wol_mode }}"
loop: "{{ en_interfaces | zip(wol_enabled.results, wol_supported.results) | list }}"
loop_control:
label: "{{ item.0 }}"
when:
- wol_mode == 'd'
- wol_mode not in item.1.stdout
changed_when: true
- name: Deploy wol systemd template
ansible.builtin.template:
src: templates/wol@.service.j2
dest: /etc/systemd/system/wol@.service
mode: '0644'
notify: Reload systemd
when: en_interfaces | length > 0
- name: Enable WOL systemd unit for each interface
ansible.builtin.systemd:
name: "wol@{{ item }}.service"
enabled: true
state: started
loop: "{{ en_interfaces }}"
when: en_interfaces | length > 0
- name: Get MAC addresses
ansible.builtin.set_fact:
wol_mac_addresses: >-
{{ wol_mac_addresses | default([]) + [ hostvars[inventory_hostname]['ansible_' ~ item].macaddress ] }}
loop: "{{ en_interfaces }}"
when: en_interfaces | length > 0
- name: Start tcpdump to capture WOL packet
become: true
ansible.builtin.shell: |
timeout 10 tcpdump -i {{ en_interfaces[0] }} -nn -c 1 \
'udp and port {{ wol_port }} and (udp[8:4] = 0xffffffff)'
register: tcpdump_result
async: 12
poll: 0
changed_when: false
- name: Give tcpdump time to start
ansible.builtin.pause:
seconds: 1
# - name: Send WOL packet via shell
# ansible.builtin.shell: wakeonlan {{ wol_mac_addresses[0] }}
# delegate_to: localhost
- name: Send Wake-on-LAN packet from localhost
community.general.wakeonlan:
mac: "{{ wol_mac_addresses[0] }}"
port: "{{ wol_port }}"
broadcast: 255.255.255.255
# delegate_to: localhost
- name: Wait for tcpdump to finish
ansible.builtin.async_status:
jid: "{{ tcpdump_result.ansible_job_id }}"
register: tcpdump_status
until: tcpdump_status.finished
retries: 12
delay: 1
- name: Check if WOL packet was received
ansible.builtin.assert:
that:
- tcpdump_status.rc == 0
success_msg: "✅ Wake-on-LAN magic packet received by host"
fail_msg: "❌ Wake-on-LAN magic packet NOT detected"
changed_when: tcpdump_status.rc == 0
- name: Report WOL configuration
ansible.builtin.debug:
msg: >
{{ wol_capabilities_check.results | map(attribute='stdout_lines') | list }}
# # ============================================================
# # Map bridges to physical NICs using Ansible facts
# # ============================================================
# - name: Get bridge link information
# ansible.builtin.command: "bridge link show"
# register: bridge_links
# changed_when: false
# check_mode: false
# - name: Initialize detected interfaces dictionary
# ansible.builtin.set_fact:
# wol_detected_interfaces: {}
# - name: Detect physical NIC for each bridge
# ansible.builtin.set_fact:
# wol_detected_interfaces: >-
# {{
# wol_detected_interfaces | combine({
# item: (
# bridge_links.stdout_lines
# | select('search', 'master ' ~ item)
# | map('regex_replace', '^\\d+: ([a-z0-9@.]+):.*$', '\\1')
# | reject('search', '^(veth|tap|fw)')
# | reject('search', '^\\d+:')
# | select('in', wol_supported_interfaces)
# | first | default('')
# )
# })
# }}
# loop: "{{ wol_bridges_list }}"
# loop_control:
# label: "{{ item }}"
# - name: Check for bond0 backing
# when: bond_info.rc == 0
# block:
# - name: Detect if any bridge is backed by bond0
# ansible.builtin.set_fact:
# wol_has_bond0: "{{ wol_detected_interfaces.values() | select('search', 'bond0') | length > 0 }}"
# - name: Extract bond0 slaves if present
# ansible.builtin.set_fact:
# wol_bond0_slaves: >-
# {{
# (bond_info.stdout | regex_findall('Slave Interface: ([a-zA-Z0-9]+)')) | list
# }}
# when: wol_has_bond0 | default(false)
# # ============================================================
# # Validate configuration and resolve to physical NICs
# # ============================================================
# - name: Fail if any bridge backing NIC could not be detected
# ansible.builtin.fail:
# msg: >
# Unable to detect physical NIC backing bridge(s): {{ unresolved_bridges | join(', ') }}.
# Please verify bridges exist and are backed by WOL-capable interfaces.
# Available WOL-capable interfaces: {{ wol_supported_interfaces | join(', ') }}
# vars:
# unresolved_bridges: "{{ wol_detected_interfaces | dict2items | selectattr('value', 'equalto', '') | map(attribute='key') | list }}"
# when: unresolved_bridges | length > 0
# - name: Build final WOL interfaces list (deduped physical NICs)
# ansible.builtin.set_fact:
# wol_final_interfaces: "{{ wol_detected_interfaces.values() | unique | list }}"
# # ============================================================
# # Check current WOL status to ensure idempotency
# # ============================================================
# - name: Get current WOL status
# ansible.builtin.command: "ethtool {{ item }}"
# register: wol_current_status
# changed_when: false
# failed_when: false
# loop: "{{ wol_final_interfaces }}"
# loop_control:
# label: "{{ item }}"
# - name: Build list of NICs needing WOL enabled
# ansible.builtin.set_fact:
# wol_needs_enable: >-
# {{
# wol_current_status.results
# | selectattr('stdout', 'search', 'Wake-on: [^g]')
# | map(attribute='item')
# | list
# }}
# # ============================================================
# # Enable WOL immediately (only if needed)
# # ============================================================
# - name: Enable Wake-on-LAN immediately on NICs
# ansible.builtin.command: "ethtool -s {{ item }} wol {{ wol_mode }}"
# register: wol_enable_result
# changed_when: true
# loop: "{{ wol_needs_enable }}"
# loop_control:
# label: "{{ item }}"
# when: wol_needs_enable | length > 0
# # ============================================================
# # Persist WOL via udev rules (safe and idempotent)
# # ============================================================
# - name: Create udev rule content
# ansible.builtin.set_fact:
# wol_udev_rules: >-
# {{
# wol_final_interfaces
# | map('regex_replace', '^(.+)$', 'ACTION=="add", SUBSYSTEM=="net", KERNEL=="\1", RUN+="/sbin/ethtool -s \1 wol {{ wol_mode }}"')
# | list
# }}
# - name: Create/Update udev rules file
# ansible.builtin.copy:
# dest: /etc/udev/rules.d/90-wol.rules
# owner: root
# group: root
# mode: "0644"
# content: |
# # Wake-on-LAN udev rules - Auto-generated by Ansible
# # Applies to: {{ wol_final_interfaces | join(', ') }}
# {% for rule in wol_udev_rules %}
# {{ rule }}
# {% endfor %}
# notify:
# - Reload_udev_rules
# - Trigger_udev_net
# # ============================================================
# # Verification & Reporting
# # ============================================================
# - name: Verify Wake-on-LAN status
# ansible.builtin.command: "ethtool {{ item }}"
# register: wol_status
# changed_when: false
# loop: "{{ wol_final_interfaces }}"
# loop_control:
# label: "{{ item }}"
# when: wol_verify
# - name: Display WOL status per interface
# ansible.builtin.debug:
# msg: >
# Interface {{ item.item }} WOL Status:
# {{ item.stdout_lines | select('search', 'Wake-on:') | first | default('Status Unknown') }}
# loop: "{{ wol_status.results | default([]) }}"
# loop_control:
# label: "{{ item.item }}"
# when: wol_verify
# - name: Get MAC addresses for all interfaces
# ansible.builtin.set_fact:
# wol_mac_addresses: >-
# {{
# wol_final_interfaces
# | map('extract', hostvars[inventory_hostname]['ansible_' ~ item] | default({}), 'macaddress')
# | list
# }}
# - name: Report WOL configuration
# ansible.builtin.debug:
# msg: |
# Wake-on-LAN Configuration Summary:
# ===================================
# Bridges Configured: {{ wol_bridges_list | join(', ') }}
# Physical Interfaces: {{ wol_final_interfaces | join(', ') }}
# WOL Mode: {{ wol_mode }}
# {% if wol_has_bond0 | default(false) %}
# Bond0 Detected: Yes
# Bond0 Slaves: {{ wol_bond0_slaves | join(', ') }}
# {% endif %}
# {% if wol_report_mac and wol_mac_addresses | length > 0 %}
# MAC Addresses:
# {% for iface, mac in (wol_final_interfaces | zip(wol_mac_addresses) | list) %}
# - {{ iface }}: {{ mac | default('Unable to detect') }}
# {% endfor %}
# {% endif %}
msg: |
Wake-on-LAN Configuration Summary:
===================================
Physical Interfaces: {{ en_interfaces | join(', ') }}
WOL Mode: {{ wol_mode }}
MAC Addresses: {{ wol_mac_addresses | join(', ') }}

View File

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

13
templates/wol@.service.j2 Normal file
View File

@@ -0,0 +1,13 @@
# /etc/systemd/system/wol@.service
[Unit]
Description=WakeonLAN configuration for interface %I
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/ethtool -s %I wol {{ wol_mode }}
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target