Files
ansible_proxmox_WOL/templates/wol-interfaces.service.j2
Jose 93d14fedbe
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
refactor ♻️: Refactor ExecStart to use a list for commands and conditionally execute them.
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 11:07:00 +01:00

19 lines
555 B
Django/Jinja

[Unit]
Description=Set Wake-on-LAN on network interfaces
After=network.target
Wants=network.target
[Service]
Type=oneshot
ExecStart=/bin/bash -c '{% set cmds = [] %}
{% for intf, enabled, supported in en_interfaces | zip(wol_enabled.results, wol_supported.results) %}
{% if wol_mode in supported.stdout and wol_mode not in enabled.stdout %}
{% set _ = cmds.append("/sbin/ethtool -s " ~ intf ~ " wol " ~ wol_mode) %}
{% endif %}
{% endfor %}
{{ cmds | join("; ") if cmds | length > 0 else ":" }}'
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target