This commit is contained in:
2025-10-21 08:17:22 +02:00
parent 91e4942de8
commit 0de7960a3a
5 changed files with 94 additions and 43 deletions

View File

@@ -10,23 +10,20 @@
ansible.builtin.set_fact:
active_adapter: '{{ item }}'
loop: '{{ ansible_facts.interfaces }}'
when: 'item.startswith("eno")'
- name: Display all interfaces name
ansible.builtin.debug:
msg: "{{ ansible_default_ipv4.interface }}"
when: '(item.startswith("eno") or item.startswith("enp")) and not item.endswith("avahi")'
- name: Creating config
become: true
ansible.builtin.copy:
dest: "/etc/systemd/system/wol.service"
dest: "/etc/systemd/system/wol@.service"
content: |
[Unit]
Description=Enable Wake On Lan
[Service]
Type=oneshot
ExecStart = /usr/sbin/ethtool --change {{ ansible_default_ipv4.interface }} wol g
ExecStart = /usr/sbin/ethtool --change %i wol g
[Install]
WantedBy=basic.target
@@ -34,7 +31,9 @@
mode: '0744'
- name: Restart service wol, in all cases
ansible.builtin.service:
name: wol
name: wol@{{ item }}
state: restarted
enabled: true
become: true
loop: '{{ ansible_facts.interfaces }}'
when: '(item.startswith("eno") or item.startswith("enp")) and not item.endswith("avahi")'